public void Save_and_Load_FrameworkConfiguratoinExtension_Test()
        {
            var filename = "configuration.ioc.config";

            var mockTypes = new Type[]
            {
                typeof(MockSimple),
            };

            var catalog = new FrameworkTypeCatalog(mockTypes);
            var visitor = new FrameworkDependencyVisitor(catalog);
            var root    = visitor.VisitTypes();

            var xs = new XmlSerializer(typeof(UmcCoreIoCElement));

            using (StreamWriter sw = new StreamWriter(filename))
            {
                xs.Serialize(sw, root);
            }

            TestContext.WriteLine(File.ReadAllText(filename));


            IFrameworkContainer newContainer = new FrameworkContainerForUnity();

            newContainer.Load(filename);

            TestContext.WriteLine(newContainer.Resolve <IMockSimple>().GetHashCode().ToString());
        }
예제 #2
0
        public void FrameworkContainerComposition_with_DynamicAttribute_Test()
        {
            var container = new FrameworkContainerForUnity();

            var catalog = new FrameworkTypeCatalog(new Type[] { typeof(IEntity), typeof(Entity), typeof(DynamicObject_Tests), typeof(Unity_Component_Tests) });
            var visitor = new FrameworkDependencyVisitor(catalog);



            var root      = visitor.VisitTypes();
            var composite = new FrameworkCompositionResolverForUnity(container, root);

            composite.Compose();

            //XmlSerializer xs = new XmlSerializer(typeof(UmcCoreIoCElement));
            //xs.Serialize(Console.Out, root);

            var entity = container.Resolve <IEntity>();

            entity.Name = "Junil, Um";
            Console.WriteLine("Name={0}", entity.Name);

            entity = container.Resolve <IEntity>();
            Console.WriteLine("Name={0}", entity.Name);
        }
        private FrameworkContainerForUnity CompositionTheTypes(Type[] types)
        {
            var visitor = new FrameworkDependencyVisitor(types);
            var root    = visitor.VisitTypes();

            WriteToSerialization(root);

            var container = new FrameworkContainerForUnity();
            var resolver  = new FrameworkCompositionResolverForUnity(container, root);

            resolver.Compose();
            return(container);
        }