예제 #1
0
 /// <summary>
 /// Gets the duck type instance for the object implementing a base class or interface T
 /// </summary>
 /// <param name="instance">Object instance</param>
 /// <typeparam name="T">Target type</typeparam>
 /// <returns>DuckType instance</returns>
 public static T As <T>(this object instance)
 => DuckType.Create <T>(instance);
예제 #2
0
 /// <summary>
 /// Gets the duck type instance for the object implementing a base class or interface T
 /// </summary>
 /// <param name="instance">Object instance</param>
 /// <param name="targetType">Target type</param>
 /// <returns>DuckType instance</returns>
 public static object As(this object instance, Type targetType)
 => DuckType.Create(targetType, instance);
예제 #3
0
 public static T?DuckCast <T>(this object?instance)
 => DuckType.Create <T>(instance);