fx-sharp  0.1
A collection of functional extensions for C#.
 All Classes Namespaces Files Functions Variables Enumerator
ObjectExtensions.cs
Go to the documentation of this file.
1 namespace FxSharp.Extensions
2 {
3  public static class ObjectExtensions
4  {
5  public static T Identity<T>(this T t)
6  {
7  return Prelude.Id(t);
8  }
9 
10  public static T Constant<T>(this T a, T b)
11  {
12  return Prelude.Const(a, b);
13  }
14 
15  /// <summary>
16  /// Cast safely to the given type.
17  /// </summary>
18  /// <typeparam name="T">Type to cast to.</typeparam>
19  /// <param name="value">Object to be casted.</param>
20  /// <returns>The wrapped value.</returns>
21  public static Maybe<T> As<T>(this object value)
22  where T : class
23  {
24  return (value as T).ToMaybe();
25  }
26  }
27 }
Property</c ></item > *< item >< c > value