Пример #1
0
        static void Main(string[] args)
        {
            var ctor = typeof(Cat).GetExportableConstructor();

            var ctp = ctor.GetCtorParameters();

            var createdActivator = GetActivator <Cat>(ctor);
            Cat instance         = createdActivator(ctp);

            Console.WriteLine(instance.Says());

            //var p = ctor.GetCtorParameters() as ParameterInfo[];
            ////var le = Expression.Lambda(
            ////                            Expression.New(ctor,p.Select(x => Expression.Parameter(x.GetType()))));

            ////var le = Expression.Lambda(Expression.New(ctor, p.Select(x => Expression.Parameter(x.GetType()))),p.Select(y => y));

            ////var lambda = Expression.Lambda(Expression.New(ctor, p.Select(x => Expression.Parameter(x.ParameterType, x.Name))));

            //var lambda = Expression.Lambda(Expression.New(ctor, Expression.Parameter(typeof(IZoo)), Expression.Parameter(typeof(IManager))));
            //var func = lambda.Compile();

            //var asas = func.DynamicInvoke(new DallasZoo(), new MrJones());
            //Console.WriteLine(asas.GetType());
            //Export<IA>.Add(new A());

            //var exp =  Export<IA>.GetAll();
            //Console.WriteLine(exp.Count);
            //Console.WriteLine(Export<IA>.Exports.Count);

            //Mozart.Compose.Init();

            //var animals = Mozart.Compose<IZoo>.Get();
            //Console.WriteLine(animals.Name);


            //Compose.ExportedInterfaceFactory.Clear();

            Compose.Init();
            //Act
            var obj = ReflectionHelpers.GetInstance <Cat>();

            // Assert
            Console.WriteLine(obj.Says());

            Console.ReadLine();
        }