ImpromptuInterface/src/Impromptu.cs
/// <summary>
/// Extension Method that Wraps an existing object with an Explicit interface definition
/// </summary>
/// <typeparam name="TInterface">The type of the interface.</typeparam>
/// <param name="originalDynamic">The original object can be annoymous type, System.DynamicObject as well as any others.</param>
/// <param name="otherInterfaces">Optional other interfaces.</param>
/// <returns></returns>
Extension Method that Wraps an existing object with an Explicit interface definition
Extension Method that Wraps an existing object with an Explicit interface definition
public static TInterface ActLike<TInterface>(this object originalDynamic, params Type[] otherInterfaces) where TInterface : class
        {
            Type tContext;
            bool tDummy;
            originalDynamic = originalDynamic.GetTargetContext(out tContext, out tDummy);
            tContext = tContext.FixContext();
            var tProxy = BuildProxy.BuildType(tContext, typeof(TInterface), otherInterfaces);
            return
                (TInterface)
                InitializeProxy(tProxy, originalDynamic, new[] {typeof (TInterface)}.Concat(otherInterfaces));
        }
public static TInterface ActLike < TInterface > ( this object originalDynamic , params Type [ ] otherInterfaces ) where TInterface : class { Type tContext ; bool tDummy ; originalDynamic = originalDynamic . GetTargetContext ( out tContext , out tDummy ) ; tContext = tContext . FixContext ( ) ; var tProxy = BuildProxy . BuildType ( tContext , typeof ( TInterface ) , otherInterfaces ) ; return ( TInterface ) InitializeProxy ( tProxy , originalDynamic , new [ ] { typeof ( TInterface ) } . Concat ( otherInterfaces ) ) ; }
Extension Method that Wraps an existing object with an Explicit interface definition
Extension Method that Wraps an existing object with an Explicit interface definition
None
object
this
<not_specific>
originalDynamic
<not_specific>
The original object can be annoymous type, System.DynamicObject as well as any others.
The original object can be annoymous type System . DynamicObject as well as any others .
otherInterfaces
<not_specific>
Optional other interfaces.
Optional other interfaces .
typeparam
The type of the interface.
The type of the interface .