本文整理汇总了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<>));
}
示例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> ();
}