ekonbenefits / impromptu-interface

Static interface to dynamic implementation (duck casting). Uses the DLR combined with Reflect.Emit.
Apache License 2.0
655 stars 67 forks source link

Feature Request: ActLike<BaseClass> #24

Open meikeric opened 6 years ago

meikeric commented 6 years ago

Add ability to pass a Base Class Type to ActLike and have it generate that object. Reasoning: Dynamic Entity Framework Core.

Sample Unit Test Usage for Entity Framework:

            dynamic testObject = new ExpandoObject();

            //dynamic testObjectContext = testObject.ActLike<DbContext>();
            dynamic testObjectContext = Impromptu.ActLike<DbContext>(testObject);

            Type testObjectContextType = testObjectContext.GetType();

            Assert.True(testObjectContextType.IsSubclassOf(typeof(DbContext)));