本文整理汇总了C#中IServiceRegistry.Register方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceRegistry.Register方法的具体用法?C# IServiceRegistry.Register怎么用?C# IServiceRegistry.Register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceRegistry
的用法示例。
在下文中一共展示了IServiceRegistry.Register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
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));
}
示例2: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
serviceRegistry.Register<IAspectSerializer, AspectDataContractSerializer>(typeof(AspectDataContractSerializer).FullName, new PerContainerLifetime());
serviceRegistry.Register<IAspectSerializer, AspectXmlSerializer>(typeof(AspectXmlSerializer).FullName, new PerContainerLifetime());
serviceRegistry.Register<IAspectSerializerFactory, AspectSerializerFactory>(new PerContainerLifetime());
}
示例3: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
serviceRegistry.RegisterFrom<CommonCompositionRoot>();
serviceRegistry.RegisterFrom<ThreeProducibleUnitsCompositionRoot>();
serviceRegistry.Register<IWorldAge, LinearWorldAge>(new PerContainerLifetime());
serviceRegistry.Register<IWinnerStrategy, RedWinsIn3000Bce>(new PerContainerLifetime());
}
示例4: Load
public void Load(IServiceRegistry registry)
{
if (!registry.IsRegistered(typeof (IEventAggregator)))
{
registry.Register<IEventAggregator, EventAggregator>(true);
}
registry.Register<IMessageBus, PrismMessageBus>(true);
}
示例5: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
serviceRegistry.RegisterFrom<CommonCompositionRoot>();
serviceRegistry.RegisterFrom<FourProducibleUnitsCompositionRoot>();
serviceRegistry.Register<IWorldAge, DeceleratingWorldAge>(new PerContainerLifetime());
serviceRegistry.Register<IWinnerStrategy, CityConquerorWins>(new PerContainerLifetime());
}
示例6: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
var players = new[] { new Player("Red"), new Player("Blue") };
serviceRegistry.Register(_ => players, new PerContainerLifetime());
serviceRegistry.Register<RoundRobinTurns>(new PerContainerLifetime());
serviceRegistry.Register<ITurnTaking>(c => c.GetInstance<RoundRobinTurns>());
serviceRegistry.Register<INotifyBeginningNextRound>(c => c.GetInstance<RoundRobinTurns>());
}
示例7: Scan
public void Scan(Assembly assembly, IServiceRegistry serviceRegistry, Func<LightInject.ILifetime> lifetimeFactory, Func<Type, Type, bool> shouldRegister)
{
var serviceTypes = namedTypeExtractor.Execute(assembly);
foreach (var type in serviceTypes)
{
foreach (NamedAttribute attr in type.GetCustomAttributes(typeof(NamedAttribute), false))
{
Type serviceType = attr.ServiceType;
if (serviceType == null)
{
var interfaces = type.GetInterfaces();
if (interfaces.Length != 1)
{
throw new ArgumentException("As service type not specified, a unique interface is required to be implemented or inherited by the type, or a base class is required to be inherited by the type, please supply the parameter value explicitly.", "ServiceType");
}
serviceType = interfaces[0];
}
LightInject.ILifetime lifetime;
if (attr.LifetimeType != null)
{
if (!typeof(ILifetime).IsAssignableFrom(attr.LifetimeType))
{
throw new ArgumentException("Type is not an implementation of the ILifetime interface.", "LifetimeType");
}
if (attr.LifetimeType == typeof(PerContainerLifetime))
{
lifetime = new LightInject.PerContainerLifetime();
}
else if (attr.LifetimeType == typeof(PerLookupLifetime))
{
lifetime = null;
}
else
{
lifetime = new AdapterLifetime((ILifetime)Activator.CreateInstance(attr.LifetimeType));
}
}
else
{
lifetime = new LightInject.PerContainerLifetime();
}
if (attr.ServiceName == null)
{
serviceRegistry.Register(serviceType, type, lifetime);
}
else
{
serviceRegistry.Register(serviceType, type, attr.ServiceName, lifetime);
}
}
}
}
示例8: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
serviceRegistry.RegisterFrom<TwoPlayersCompositionRoot>();
serviceRegistry.RegisterFrom<CitiesCompositionRoot>();
serviceRegistry.RegisterFrom<TerrainsCompositionRoot>();
serviceRegistry.RegisterFrom<UnitsCompositionRoot>();
serviceRegistry.Register<IUnitCombat, AttackerIsAlwaysVictorious>(new PerContainerLifetime());
serviceRegistry.Register<IGame, ExtenCivGame>(new PerContainerLifetime());
}
示例9: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
serviceRegistry.Register(f => CreateNhSessionFactory(), new PerContainerLifetime());
serviceRegistry.RegisterAssembly(typeof(NhPersonRepository).Assembly);
serviceRegistry.RegisterAssembly(typeof(PersonService).Assembly);
serviceRegistry.Register<UnitOfWorkInterceptor>();
serviceRegistry.Intercept(sr => sr.ImplementingType != null && sr.ImplementingType.GetMethods().Any(m => m.IsDefined(typeof(UnitOfWorkAttribute), true)), f => f.GetInstance<UnitOfWorkInterceptor>());
}
示例10: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
serviceRegistry.RegisterAssembly(typeof (ITerrain<>).Assembly,
(_, t) => t.IsTerrain());
serviceRegistry.RegisterAssembly(typeof (ITerrainFactory<>).Assembly,
() => new PerContainerLifetime(),
(_, t) => t.IsTerrainFactory());
serviceRegistry.Register<ISet<ITerrain>>(_ => new HashSet<ITerrain>(new TerrainEqualityComparer()),
new PerContainerLifetime());
serviceRegistry.Register<ITerrainLayer, SimpleFixedTerrainLayer>(new PerContainerLifetime());
}
示例11: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
serviceRegistry.RegisterAssembly(typeof (ICity<>).Assembly,
(_, t) => t.IsCity());
serviceRegistry.RegisterAssembly(typeof (ICityFactory<>).Assembly,
() => new PerContainerLifetime(),
(_, t) => t.IsCityFactory());
serviceRegistry.Register<ISet<ICity>>(_ => new HashSet<ICity>(new CityEqualityComparer()),
new PerContainerLifetime());
serviceRegistry.Register<ICityLayer, SimpleFixedCityLayer>(new PerContainerLifetime());
}
示例12: typeof
void ICompositionRoot.Compose(IServiceRegistry serviceRegistry)
{
CallCount++;
serviceRegistry.Register<IFoo,Foo>();
serviceRegistry.RegisterFallback((type, s) => type == typeof(IBar), request => new Bar());
}
示例13: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
serviceRegistry.Register<IIconKeeperService, IconKeeperService>();
serviceRegistry.Register<IQueryExecutor>(factory => new QueryExecutor((IServiceFactory)serviceRegistry));
serviceRegistry.Register<ICommandExecutor>(factory => new CommandExecutor((IServiceFactory)serviceRegistry));
serviceRegistry.Register<IDbConnection>(factory => CreateMySqlConnection(factory), new PerScopeLifetime());
serviceRegistry.Register<IQueryHandler<IconQuery, IEnumerable<IconResult>>, IconQueryHandler>();
serviceRegistry.Register<ICommandHandler<Icon.Icon>, CreateIconCommandHandler>();
serviceRegistry.Register<ICommandHandler<DeleteIconCommand>, DeleteIconCommandHandler>();
serviceRegistry.Register<ICommandHandler<IncrementDownloadsCommand>, IncrementDownloadsCommandHandler>();
serviceRegistry.Register<ICommandHandler<UpdateIconCommand>, UpdateIconCommandHandler>();
serviceRegistry.Register<IConfiguration, AppSettingsConfiguration>(new PerContainerLifetime());
}
示例14: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
serviceRegistry.RegisterAssembly("DrawPub*.dll");
serviceRegistry.Register<IInterceptor, LogInterceptor>("LogInterceptor");
serviceRegistry.Intercept(sr => sr.ServiceType == typeof(IUserAppplicationService), DefineProxyType);
serviceRegistry.Intercept(sr => sr.ServiceType == typeof(IUserRepository), DefineProxyType);
serviceRegistry.Intercept(sr => sr.ServiceType == typeof(IConnectionProvider), DefineProxyType);
}
示例15: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
serviceRegistry.RegisterAssembly(typeof (IUnit<>).Assembly,
(_, t) => t.IsUnit());
serviceRegistry.RegisterAssembly(typeof (IUnitFactory<>).Assembly,
() => new PerContainerLifetime(),
(_, t) => t.IsUnitFactory());
serviceRegistry.RegisterAssembly(typeof(IProductionProject).Assembly,
() => new PerContainerLifetime(),
(_, t) => t.IsProductionProject());
serviceRegistry.Register<ISet<IUnit>>(_ => new HashSet<IUnit>(new UnitEqualityComparer()),
new PerContainerLifetime());
serviceRegistry.Register<IUnitLayer, SimpleFixedUnitLayer>(new PerContainerLifetime());
}