/// <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);
/// <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);
public static T?DuckCast <T>(this object?instance) => DuckType.Create <T>(instance);