Exemplo n.º 1
0
        public static void RegisterFoo2()
        {
            var class1 = new Class1();
            class1.Id = Guid.NewGuid().ToString();

            var builder = new ContainerBuilder();
            builder.RegisterInstance(class1);

            IContainer container =  builder.Build();
            Class1 c1 = container.Resolve<Class1>();
            Console.WriteLine(c1.Id);
        }
Exemplo n.º 2
0
        public static void LambdaFoo()
        {
            var builder = new ContainerBuilder();
            builder.Register(cc => { var class1 = new Class1();
            while (string.IsNullOrEmpty(class1.Id))
            {
                class1.Id = Guid.NewGuid().ToString();
            }
                return class1; });

            IContainer container = builder.Build();
            Class1 class1_0 = container.Resolve<Class1>();
            Console.WriteLine(class1_0.Id);
        }