I think C # is not yet "dynamic" enough to do what I think you need.
The And method will not work, since the entity
parameter is of type object
, so entity.method(parent)
will not work. Even if you define entity
as a dynamic
type, C # will try to find a method called a "method" to call. You can do this in your example:
public static dynamic And(this Object entity, Action method, object parameter) { method(entity, parameter); return entity; }
and
dynamic entity = MakeNew(type).And(AddTo, parameter);
Sweko source share