当前位置: 首页>>代码示例>>C#>>正文


C# IServiceRegistry.Decorate方法代码示例

本文整理汇总了C#中IServiceRegistry.Decorate方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceRegistry.Decorate方法的具体用法?C# IServiceRegistry.Decorate怎么用?C# IServiceRegistry.Decorate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServiceRegistry的用法示例。


在下文中一共展示了IServiceRegistry.Decorate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Compose

        /// <summary>
        /// Composes services by adding services to the <paramref name="serviceRegistry"/>.
        /// </summary>
        /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
        public void Compose(IServiceRegistry serviceRegistry)
        {
            serviceRegistry.Register<IColumnSelector, ColumnSelector>(new PerGraphLifetime());
            serviceRegistry.Decorate(typeof(IColumnSelector), typeof(CachedColumnSelector));
            serviceRegistry.Register<IConstructorSelector, ConstructorSelector>(new SingletonLifetime());
            serviceRegistry.Decorate(typeof(IConstructorSelector), typeof(CachedConstructorSelector));
            serviceRegistry.Register(typeof(IDataReaderMapper<>), typeof(DataReaderMapper<>));
            serviceRegistry.Register(typeof(IDataRecordMapper<>), typeof(DataRecordMapper<>), new PerGraphLifetime());

            serviceRegistry.Register<IKeyDelegateBuilder, KeyDelegateBuilder>(new PerGraphLifetime());
            serviceRegistry.Decorate(typeof(IKeyDelegateBuilder), typeof(CachedKeyDelegateBuilder));

            serviceRegistry.Register(typeof(IInstanceDelegateBuilder<>), typeof(InstanceDelegateBuilder<>), new PerGraphLifetime());
            serviceRegistry.Decorate(typeof(IInstanceDelegateBuilder<>), typeof(CachedInstanceDelegateBuilder<>));

            serviceRegistry.Register<IOrdinalSelector, OrdinalSelector>(new PerGraphLifetime());
            serviceRegistry.Decorate(typeof(IOrdinalSelector), typeof(CachedOrdinalSelector));

            serviceRegistry.Register(typeof(IRelationDelegateBuilder<>), typeof(ManyToOneDelegateBuilder<>), "ManyToOneDelegateBuilder", new PerGraphLifetime());
            serviceRegistry.Register(typeof(IRelationDelegateBuilder<>), typeof(OneToManyDelegateBuilder<>), "OneToManyDelegateBuilder", new PerGraphLifetime());
            serviceRegistry.Decorate(typeof(IRelationDelegateBuilder<>), typeof(CachedRelationDelegateBuilder<>));

            serviceRegistry.Register(typeof(IInstanceExpressionBuilder<>), typeof(InstanceExpressionBuilder<>));

            serviceRegistry.Register(typeof(IMapperDelegateBuilder<>), typeof(ConstructorMapperDelegateBuilder<>), "ConstructorMapperDelegateBuilder", new SingletonLifetime());
            serviceRegistry.Register(typeof(IMapperDelegateBuilder<>), typeof(PropertyMapperDelegateBuilder<>), "PropertyMapperDelegateBuilder", new SingletonLifetime());

            serviceRegistry.Register(typeof(IMethodSkeleton<>), typeof(DynamicMethodSkeleton<>));

            serviceRegistry.Register<IMethodSelector, MethodSelector>(new SingletonLifetime());
            serviceRegistry.Decorate(typeof(IMethodSelector), typeof(CachedMethodSelector));

            serviceRegistry.Register(typeof(IManyToOneDelegateBuilder<>), typeof(ManyToOneDelegateBuilder<>));

            serviceRegistry.Register<Interfaces.IPropertySelector, Implementation.PropertySelector>(new SingletonLifetime());
            serviceRegistry.Register<Interfaces.IPropertySelector, ComplexPropertySelector>("ComplexPropertySelector", new SingletonLifetime());
            serviceRegistry.Register<Interfaces.IPropertySelector, CollectionPropertySelector>("CollectionPropertySelector", new SingletonLifetime());
            serviceRegistry.Decorate(typeof(Interfaces.IPropertySelector), typeof(CachedPropertySelector));

            serviceRegistry.Register<IPropertyMapper, PropertyMapper>(new PerGraphLifetime());
            serviceRegistry.Decorate(typeof(IPropertyMapper), typeof(CachedPropertyMapper));

            serviceRegistry.Register<IMapperDelegateBuilder<IStructuralEquatable>, ConstructorMapperDelegateBuilder<IStructuralEquatable>>("keyInstanceEmitter");
            serviceRegistry.Register<IOneToManyExpressionBuilder>(
                factory =>
                new OneToManyExpressionBuilder(
                    factory.GetInstance<IPropertyMapper>(), factory.GetInstance<Interfaces.IPropertySelector>("CollectionPropertySelector"), type => factory.GetInstance(type)));
            serviceRegistry.Register<IManyToOneExpressionBuilder>(
                factory =>
                new ManyToOneExpressionBuilder(
                    factory.GetInstance<IPropertyMapper>(), factory.GetInstance<Interfaces.IPropertySelector>("ComplexPropertySelector"), type => factory.GetInstance(type)));
            serviceRegistry.Decorate(typeof(IMapperDelegateBuilder<>), typeof(CachedMapperDelegateBuilder<>));
        }
开发者ID:seesharper,项目名称:DbExtensions,代码行数:57,代码来源:CompositionRoot.cs

示例2: Compose

        public void Compose(IServiceRegistry serviceRegistry)
        {
			var dataStorage = ConfigurationManager.AppSettings["DataStorage"];
			if (dataStorage.ToLower ().Equals ("cache")) 
			{
				serviceRegistry.Register<IDataStorage, GameScoreBoardDataCache> (); 
			}
			if (dataStorage.ToLower().Equals("database"))
			{
				var mysqlConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
				serviceRegistry.Register<IConnectionFactory>(factory => new MySqlConnectionFactory(mysqlConnectionString));
				serviceRegistry.Register<IDataStorage>(factory => new GameScoreBoardMysqlRepository(factory.GetInstance<IConnectionFactory>()));
			}
			serviceRegistry.Register<ICryptation, StringCipher> (); 
			serviceRegistry.Register<ILogFactory, Log4NetLogFactory>(new PerContainerLifetime());
			serviceRegistry.Register<Type, ILog>((factory, type) => factory.GetInstance<ILogFactory>().GetLogger(type));
			serviceRegistry.RegisterConstructorDependency(
				(factory, info) => factory.GetInstance<Type, ILog>(info.Member.DeclaringType));   
			serviceRegistry.Decorate<IDataStorage, DataStorageProfiler> ();
        }
开发者ID:andmos,项目名称:Game-Scoreboard-Server,代码行数:20,代码来源:CompositionRoot.cs


注:本文中的IServiceRegistry.Decorate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。