static void Main(string[] args) { var factory = new Factory("MyApp", new MyLogger()); // Register the type. factory.Type("MyType", typeof(MyType)); // Create an instance and pass in constructor arguments. var myFactoryCreatedObject = factory.Create<MyType>("MyType", "Hello", "Computer"); Console.WriteLine(myFactoryCreatedObject.Message); }
static void Main(string[] args) { var factory = new Factory("MyApp", new MyLogger()); // Register the type. factory.Type<IMyType>(typeof(MyType)); // Create an instance. var myFactoryCreatedObject = factory.CreateInterface<IMyType>(); Console.WriteLine(myFactoryCreatedObject.Message); }