Can I define a class which derives from DynamicObject and supports an interface (ICanDoManyThings) without having to implement each method in the interface?
I\'m trying
With Clay, you can.
An example:
public interface IMyInterface
{
string Prop1 { get; }
long Prop2 { get; }
Guid Prop3 { get; }
Func Meth { get; }
}
//usage:
dynamic factory = new ClayFactory();
var iDynamic = factory.MyInterface
(
Prop1: "Test",
Prop2: 42L,
Prop3: Guid.NewGuid(),
Meth: new Func(i => i > 5)
);
IMyInterface iStatic = iDynamic;
This article shows few more ways to achieve this.