public void ActivatorInstanceFactory_CreateInstance_Protected_Crot_Test() { //arrange Type type = typeof(Protected_Crot); object[] args = null; InstanceFactory instanceFactory = new ActivatorInstanceFactory(); //act Object obj = instanceFactory.CreateInstance(type, args); //Assert Assert.IsInstanceOfType(obj, type); }
public void ActivatorInstanceFactory_CreateInstance_Private_Ctor_With_Params_Test() { //arrange Type type = typeof(Private_Ctor_With_Params); object[] args = new object[] { "string", 1 }; InstanceFactory instanceFactory = new ActivatorInstanceFactory(); //act Object obj = instanceFactory.CreateInstance(type, args); //Assert Assert.IsInstanceOfType(obj, type); }
static void Main(string[] args) { var activatorInstanceFactory = new ActivatorInstanceFactory(); var emitInstanceFactory = new EmitInstanceFactory(); var container = new Container(activatorInstanceFactory); // Using assembly //container.AddAssembly(Assembly.GetExecutingAssembly()); // Using all types container.AddType(typeof(CustomExportWithoutInterface)); container.AddType(typeof(CustomExport), typeof(ICustomExport)); container.AddType(typeof(CustomImportConstructor)); container.AddType(typeof(CustomImportProperties)); var customImportConstructor = container.CreateInstance <CustomImportConstructor>(); var customImportProperties = container.CreateInstance <CustomImportProperties>(); customImportProperties.EnsureThatClassHasProperties(); Console.WriteLine("Instances was created."); Console.ReadKey(); }