Exemplo n.º 1
0
        public void Sample()
        {
            var container = new Container();

            container.AddAssembly(Assembly.GetExecutingAssembly());

            var customerBLL  = (CustomerBLL)container.CreateInstance(typeof(CustomerBLL));
            var customerBLL2 = container.CreateInstance <CustomerBLL>();

            container.AddType(typeof(CustomerBLL));
            container.AddType(typeof(Logger));
            container.AddType(typeof(CustomerDAL), typeof(ICustomerDAL));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var container = new MyIoC.Container();

            container.AddAssembly(Assembly.GetExecutingAssembly());

            container.AddType(typeof(CustomerBLL));
            //container.AddType(typeof(Logger));
            container.AddType(typeof(CustomerDAL), typeof(ICustomerDAL));

            var customerBLL = (CustomerBLL)container.CreateInstance(typeof(CustomerBLL));

            Console.WriteLine(customerBLL);
            var customerBLL2 = container.CreateInstance <CustomerBLL2>();

            Console.WriteLine(customerBLL2);

            Console.ReadLine();
        }