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


C# IServiceRegistry.Register方法代码示例

本文整理汇总了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));            
 }
开发者ID:seesharper,项目名称:Blog.WebApiRequestLogging,代码行数:7,代码来源:CompositionRoot.cs

示例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());
        }
开发者ID:raulnq,项目名称:Jal.Aop,代码行数:8,代码来源:AspectSerializerCompositionRoot.cs

示例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());
        }
开发者ID:SPDiswal,项目名称:ExtenCiv,代码行数:8,代码来源:AlphaCivCompositionRoot.cs

示例4: Load

 public void Load(IServiceRegistry registry)
 {
     if (!registry.IsRegistered(typeof (IEventAggregator)))
     {
         registry.Register<IEventAggregator, EventAggregator>(true);
     }
     registry.Register<IMessageBus, PrismMessageBus>(true);
 }
开发者ID:ChristianEder,项目名称:Cherry,代码行数:8,代码来源:PrismMessageBusModule.cs

示例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());
        }
开发者ID:SPDiswal,项目名称:ExtenCiv,代码行数:8,代码来源:SemiCivCompositionRoot.cs

示例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>());
        }
开发者ID:SPDiswal,项目名称:ExtenCiv,代码行数:9,代码来源:TwoPlayersCompositionRoot.cs

示例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);
                    }
                }
            }
        }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:56,代码来源:AssemblyScanner.cs

示例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());
        }
开发者ID:SPDiswal,项目名称:ExtenCiv,代码行数:11,代码来源:CommonCompositionRoot.cs

示例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>());
        }
开发者ID:renatohh,项目名称:PhoneBook,代码行数:12,代码来源:PhoneBookCompositionRoot.cs

示例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());
        }
开发者ID:SPDiswal,项目名称:ExtenCiv,代码行数:14,代码来源:TerrainsCompositionRoot.cs

示例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());
        }
开发者ID:SPDiswal,项目名称:ExtenCiv,代码行数:14,代码来源:CitiesCompositionRoot.cs

示例12: typeof

        void ICompositionRoot.Compose(IServiceRegistry serviceRegistry)
        {
            CallCount++;
            serviceRegistry.Register<IFoo,Foo>();

            serviceRegistry.RegisterFallback((type, s) => type == typeof(IBar), request => new Bar());
        }
开发者ID:vitamink,项目名称:LightInject,代码行数:7,代码来源:CompositionRoot.cs

示例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());
        }
开发者ID:Yazurka,项目名称:IconKeeper,代码行数:17,代码来源:CompositionRoot.cs

示例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);
        }
开发者ID:GNewsCo,项目名称:DrawPub,代码行数:9,代码来源:CompositionRoot.cs

示例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());
        }
开发者ID:SPDiswal,项目名称:ExtenCiv,代码行数:18,代码来源:UnitsCompositionRoot.cs


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