Example #1
0
        public void CatalogSetup()
        {
            var catalog        = new AggregateCatalog(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
            var genericCatalog = new GenericCatalog(catalog);
            var container      = new CompositionContainer(genericCatalog);


            container.GetExportedValue <TEMP>().Say();

            container.GetExportedValueOrDefault <IUMC <string> >();
            container.GetExportedValueOrDefault <IUMC <int> >();

            var res = container.GetExportedValueOrDefault <IEntityCacheViewModel <IVisitType> >();

            container.GetExportedValueOrDefault <IUMC <IEntity <IId> > >().Say();


            container.GetExportedValueOrDefault <IUMC <IEntity <IId> > >().Say();

            container.GetExportedValueOrDefault <IUMC <string> >().Say();

            container.GetExportedValue <ITwoInterface <int, string> >().Say();
            container.GetExportedValue <ITwoInterface <string, int> >().Say();

            Console.WriteLine("-------------------------");
            var c = container.GetExports(typeof(IUMC <>), null, null);

            Console.WriteLine(c.Count());

            Console.ReadLine();
        }
        public void DeleteGenericCatalog(GenericCatalog genericCatalog)
        {
            if (genericCatalog == null)
                throw new ArgumentNullException("genericCatalog");

            if(GenericCatalogAttributeExisted(genericCatalog.Id))
            {
                var attributeList = GetGenericCatalogById(genericCatalog.Id).Attributes.ToList();
                foreach (var attribute in attributeList)
                {
                    DeleteGenericCatalogAttribute(attribute);
                }

                //_genericCatalogRepository.Delete(_genericCatalogRepository
                //    .GetById(genericCatalog.Id)
                //    .Attributes);

                //cache
                _cacheManager.RemoveByPattern(GENERICCATALOG_BY_PAGE);
                _cacheManager.RemoveByPattern(GENERICCATALOG_ALL);
                _cacheManager.RemoveByPattern(GENERICCATALOG_BY_ID);
                _cacheManager.RemoveByPattern(GENERICCATALOGATTRIBUTES_BY_ID);
                _cacheManager.RemoveByPattern(GENERICCATALOG_BY_BLOCKVIEW);
                _cacheManager.RemoveByPattern(GENERICCATALOG_BY_SYSTEMNAME);
            }

            _genericCatalogRepository.Delete(genericCatalog);
        }
Example #3
0
        static void Main(string[] args)
        {
            InterceptionConfiguration cfg = new InterceptionConfiguration()
                                            .AddInterceptor(new DynamicProxyInterceptor(new LoggingInterceptor()));

            //GenericTypeCatalog typeCatalog = new GenericTypeCatalog(typeof(GenericClass<int>), typeof(IGenericInterface<>));
            //AssemblyCatalog assemblyCatalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
            //AggregateCatalog aggregateCatalog = new AggregateCatalog(assemblyCatalog, typeCatalog);
            //GenericCatalog genericCatalog = new GenericCatalog(aggregateCatalog);
            //InterceptingCatalog interceptingCatalog = new InterceptingCatalog(genericCatalog, cfg);
            //CompositionContainer container = new CompositionContainer(interceptingCatalog);

//            GenericContractTypeMapping mapping = new GenericContractTypeMapping(typeof(IGenericInterface<>), typeof(GenericClass<>));

            TypeCatalog      typeCatalog      = new TypeCatalog(typeof(SampleClass), typeof(OrderProcessor), typeof(CtorOrderProcessor));
            AssemblyCatalog  assemblyCatalog  = new AssemblyCatalog(Assembly.GetExecutingAssembly());
            GenericCatalog   genericCatalog   = new GenericCatalog(new TestGenericContractRegistry());
            AggregateCatalog aggregateCatalog = new AggregateCatalog(typeCatalog, genericCatalog);
            //CompositionContainer container = new CompositionContainer(aggregateCatalog);

            CompositionContainer container = new CompositionContainer(aggregateCatalog);
            var orderProcessor             = container.GetExportedValue <OrderProcessor>();
            var generic = container.GetExportedValue <IGenericInterface <string> >();

            CatalogExportProvider provider = new CatalogExportProvider(aggregateCatalog);

            provider.SourceProvider = provider;

            var instance = provider.GetExportedValue <ISampleInterface>();//container.GetExportedValue<ISampleInterface>();

            instance.Method1("test", 5);

            var genericInstance = provider.GetExportedValue <OrderProcessor>();//container.GetExportedValue<IGenericInterface<int>>();
            //var orderProcessor = provider.GetExportedValue<CtorOrderProcessor>();
        }
        public void ChangePublished(GenericCatalog genericCatalog)
        {
            if (genericCatalog == null)
                throw new ArgumentNullException("genericCatalog");

            genericCatalog.Published = !genericCatalog.Published;
            UpdateGenericCatalog(genericCatalog);
        }
Example #5
0
        public static CompositionContainer GenericComposite()
        {
            //var ass = Directory.GetFileSystemEntries(AppDomain.CurrentDomain.BaseDirectory, "*.dll", SearchOption.AllDirectories);
            var registry = new GenericContractRegistry(new TypeResolver(x => Path.GetFileName(x).StartsWith("DesignPattern*.dll" /*添加实现接口的dll文件名*/)));
            var catalog  = new GenericCatalog(registry);

            return(new CompositionContainer(catalog));
        }
        public void TestSetUp()
        {
            var typeCatalog = new TypeCatalog(typeof(CtorOrderProcessor), typeof(OrderProcessor));
            var genericCatalog = new GenericCatalog(new TestGenericContractRegistry());
            var aggregateCatalog = new AggregateCatalog(typeCatalog, genericCatalog);
            var provider = new CatalogExportProvider(aggregateCatalog);
            provider.SourceProvider = provider;

            ExportProvider = provider;
        }
Example #7
0
        static void Main(string[] args)
        {
            AssemblyCatalog  assemblyCatalog  = new AssemblyCatalog(Assembly.GetExecutingAssembly());
            GenericCatalog   genericCatalog   = new GenericCatalog(new GenericContractRegistry());
            AggregateCatalog aggregateCatalog = new AggregateCatalog(assemblyCatalog, genericCatalog);

            CompositionContainer container = new CompositionContainer(aggregateCatalog);
            var sampleClass = container.GetExportedValue <SampleClass>();

            sampleClass.SayHello();

            Console.ReadKey();
        }
Example #8
0
 public TheVm()
 {
     GenericCatalog = new GenericCatalog<Item>();
     GenericCatalog.AddElement(new Item() {Inten = 12});
     GenericCatalog.AddElement(new Item() {Inten = 3});
     GenericCatalog.AddElement(new Item() {Inten = 14});
     GenericCatalog.AddElement(new Item() {Inten = 5});
     GenericCatalog.AddElement(new Item() {Inten = 9});
     GenericCatalog.AddElement(new Item() {Inten = 2});
     GenericCatalog.AddElement(new Item() {Inten = 22});
     Command = new RelayCommand(GenericCatalog.RCompareIntenNorm);
     RelayCommand = new RelayCommand(GenericCatalog.CompareIntenNorm);
 }
Example #9
0
        private static CompositionContainer CreateContainer2()
        {
            // Create source catalog
            var typeCatalog = new TypeCatalog(typeof(Trampoline));

            // Create catalog which supports open-generics, pass in the registry
            var genericCatalog = new GenericCatalog(new MyGenericContractRegistry());

            // Aggregate the both catalogs
            var aggregateCatalog = new AggregateCatalog(typeCatalog, genericCatalog);

            // Create the container
            return(new CompositionContainer(aggregateCatalog));
        }
Example #10
0
        public void TestSetUp()
        {
            var typeCatalog = new TypeCatalog(
                typeof(CtorOrderProcessor),
                typeof(OrderProcessor),
                typeof(ConcreteCtorOrderProcessor),
                typeof(ConcreteOrderProcessor),
                typeof(MyCtorOrderProcessor),
                typeof(MyOrderProcessor),
                typeof(MyOrderProcessorSetterOnly),
                typeof(MultiOrderProcessor));
            var genericCatalog   = new GenericCatalog(new TestGenericContractRegistry());
            var aggregateCatalog = new AggregateCatalog(typeCatalog, genericCatalog);
            var provider         = new CatalogExportProvider(aggregateCatalog);

            provider.SourceProvider = provider;

            ExportProvider = provider;
        }
Example #11
0
 protected CatalogBase()
 {
     _catalog = new GenericCatalog <int, T>();
 }
        public void UpdateGenericCatalog(GenericCatalog genericCatalog)
        {
            if (genericCatalog == null)
                throw new ArgumentNullException("genericCatalog");

            genericCatalog.ModifiedDate = DateTime.Now;
            _genericCatalogRepository.Update(genericCatalog);

            //cache
            _cacheManager.RemoveByPattern(GENERICCATALOG_BY_PAGE);
            _cacheManager.RemoveByPattern(GENERICCATALOG_ALL);
            _cacheManager.RemoveByPattern(GENERICCATALOG_BY_ID);
            _cacheManager.RemoveByPattern(GENERICCATALOGATTRIBUTES_BY_ID);
            _cacheManager.RemoveByPattern(GENERICCATALOG_BY_BLOCKVIEW);
            _cacheManager.RemoveByPattern(GENERICCATALOG_BY_SYSTEMNAME);
        }
        public ActionResult Create(GenericCatalogModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageGenericCatalogs))
                return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var genericCatalog = new GenericCatalog();

                genericCatalog.Icon = this.FileAfterUpload();
                genericCatalog.Name = model.Name.ToTitle(TitleStyle.FirstCaps);
                genericCatalog.SystemName = model.Name.ToSystemName();
                genericCatalog.ItemOnPage = model.ItemOnPage;
                genericCatalog.SizeOnMenu = model.SizeOnMenu;
                genericCatalog.Published = model.Published;
                genericCatalog.DisplayOrder = model.DisplayOrder;
                genericCatalog.BlockViewId = Convert.ToInt32(model.BlockViewId.GetEnumValue<BlockViewType>());
                genericCatalog.TemplateId = model.TemplateId;
                genericCatalog.SEOUrlName = model.Name.ToSEName();

                _genericCatalogService.InsertGenericCatalog(genericCatalog);

                return RedirectToAction("List");
            }

            // Get Template List
            GetTemplateList();

            // Get blockView List
            GetBlockViewList();

            return View(model);
        }
        //Get Block View List
        private void GetBlockViewList()
        {
            var entity = new GenericCatalog();

            var GetBlockViewList = entity.BlockView.ToEnumList();
            ViewData["BlockViews"] = GetBlockViewList;
        }