-
Notifications
You must be signed in to change notification settings - Fork 67
UsageAdvanced
In additional to TInterface Impromptu.ActLike<TInterface>(this object target, params Type[] otherInterfaces)
there are a few variations.
Dynamic act like doesn't offer the primary interface as generic parameter so you can use it in a completely late bound way.
IEnumerable<TInterface> AllActLike<TInterface>(this IEnumerable<object> originalDynamic, params Type[] otherInterfaces)
Convenience Method for wrapping an entire list of objects with an Interface.
This method is used for compatibility sake only, it allows you to make dynamic objects consumable to API's that are expecting to access properties based on reflection.
If your target is a DynamicObject
and you want to define a static interface f#or it, and this dynamic object you have designed has an implementation to take argument names into account, then you can make sure the interface sends it's argument names with a [UseNamedArgument]
attribute.
public interface IBuilder{
INest Nester(object props);
INested Nester2(object props);
//Putting the argument on the method use named argument for all arguments
[UseNamedArgument]
INest Nester(string NameLevel1, INested Nested);
//Putting the argument on the property use named argument for all arguments after that property
INested Nester2([UseNamedArgument]string NameLevel2);
}
public interface INest
{
String NameLevel1 {get;set;}
INested Nested {get;set;}
}
public interface INested
{
string NameLevel2 {get;}
}