public static void ConfigureContainer(TinyIoCContainer container) { var opts = container.Resolve <Options>(); container.Register(typeof(ILogHandler), typeof(Logger.Log4NetLogger)).AsSingleton(); container.Register <InMemorySessionManager>().AsSingleton(); var sessionManager = container.Resolve <InMemorySessionManager>(); container.Register <ISessionHandler, InMemorySessionManager>(sessionManager); container.RegisterMultiple <IMessageLifecycleCallbackHandler>(new List <Type>() { typeof(SessionMessageLifecycleCallback), typeof(SpamManager) }).AsSingleton(); IPAddress ipAddress; if (IPAddress.TryParse(opts.IPAddress, out ipAddress) == false) { throw new ArgumentException("Failed to parse IP Address: " + opts.IPAddress); } container.Register(typeof(TorqueMasterServer), new TorqueMasterServer(container, new IPEndPoint(ipAddress, opts.Port))); }
public static TinyIoCContainer RegisterServices(this TinyIoCContainer container, IAppConfiguration appConfiguration) { container.Register <RoleService, RoleService>(); container.Register <UserService, UserService>(); container.Register <PermissionService, PermissionService>(); container.Register <GroupService, GroupService>(); container.Register <ClientService, ClientService>(); container.Register <GrainService, GrainService>(); container.Register <SecurableItemService, SecurableItemService>(); container.Register <MemberSearchService, MemberSearchService>(); container.Register <GroupMigratorService, GroupMigratorService>(); container.Register <IIdentityServiceProvider, IdentityServiceProvider>(); container.Register <IPermissionResolverService, PermissionResolverService>(); container.RegisterMultiple <IPermissionResolverService>(new List <Type> { typeof(GranularPermissionResolverService), typeof(RolePermissionResolverService), typeof(SharedGrainPermissionResolverService) }); container.Register <IEventService, EventService>(); container.Register <IEventContextResolverService, EventContextResolverService>(); RegisterEDWAdminRoleSyncService(container); return(container); }
private void UpdateContainerFromBuilder(TinyIoCContainer _container, DefaultDependencyBuilder b) { var groupedRegistrations = b.Registrations.SelectMany(r => r.RegistrationTypes.Select(contract => new { registration = r, contract = contract })).GroupBy(r => r.contract).ToArray(); foreach (var r in groupedRegistrations) { if (r.Count() > 1) { _container.RegisterMultiple(r.Key, r.Select(a => a.registration.SelfType)); } else { var registration = r.First(); var registrationType = registration.registration.GetType().GetGenericTypeDefinition(); var t = registration.registration.GetType().GetGenericArguments()[0]; if (TranslateInstanceRegistration(_container, registration.registration, t)) { } else if (TranslateConstructorRegistration(_container, registration.registration, t)) { } else if (TranslateFactoryRegistration(_container, registration.registration, t)) { } } } }
public static void ConfigureContainer(TinyIoCContainer container) { var opts = container.Resolve<Options>(); container.Register(typeof(ILogHandler), typeof(Logger.Log4NetLogger)).AsSingleton(); container.Register<InMemorySessionManager>().AsSingleton(); var sessionManager = container.Resolve<InMemorySessionManager>(); container.Register<ISessionHandler, InMemorySessionManager>(sessionManager); container.RegisterMultiple<IMessageLifecycleCallbackHandler>(new List<Type>() { typeof (SessionMessageLifecycleCallback), typeof (SpamManager) }).AsSingleton(); IPAddress ipAddress; if (IPAddress.TryParse(opts.IPAddress, out ipAddress) == false) { throw new ArgumentException("Failed to parse IP Address: " + opts.IPAddress); } container.Register(typeof(TorqueMasterServer), new TorqueMasterServer(container, new IPEndPoint(ipAddress, opts.Port))); }
private static void Initialize(IDestination destination, IBootstrapper bootstrapper) { TinyIoCContainer container = new TinyIoCContainer(); NoomResolver resolver = new NoomResolver(container); NoomCache cache = new NoomCache(); NoomTools tools = new NoomTools(resolver, cache); NoomRouter router = new NoomRouter(); NoomNavigator navigator = new NoomNavigator(router, destination, tools); container.Register <ICache>(cache); container.Register <IRouter>(router); container.Register <INavigator>(navigator); container.Register <IResolver>(resolver); container.RegisterMultiple(typeof(IModule), bootstrapper.FindAllModules()); foreach (Type type in bootstrapper.FindAllViews()) { container.Register(type); } foreach (IModule module in container.ResolveAll <IModule>()) { module.Register(router); } navigator.NavigateTo("/"); }
protected override void ConfigureApplicationContainer(TinyIoCContainer container) { base.ConfigureApplicationContainer(container); container.Register(_solution); container.Register(_fileSystem); container.RegisterMultiple<IReferenceProcessor>(new []{typeof(AddProjectReferenceProcessor), typeof(AddFileReferenceProcessor), typeof(AddGacReferenceProcessor)}); }
protected override void ConfigureApplicationContainer(TinyIoCContainer container) { base.ConfigureApplicationContainer(container); container.Register(_solution); container.Register(_fileSystem); container.RegisterMultiple <IReferenceProcessor>(new [] { typeof(AddProjectReferenceProcessor), typeof(AddFileReferenceProcessor), typeof(AddGacReferenceProcessor) }); }
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context) { container.Register <IActiveDirectoryProxy, ActiveDirectoryProxy>(); ICollection <Type> activeDirectoryProviderTypes = new List <Type>(); if (_appConfig.UseWindowsAuthentication) { activeDirectoryProviderTypes.Add(typeof(ActiveDirectoryProviderService)); } if (_appConfig.UseAzureAuthentication) { activeDirectoryProviderTypes.Add(typeof(AzureDirectoryProviderService)); } container.RegisterMultiple <IExternalIdentityProviderService>(activeDirectoryProviderTypes); container.Register <PrincipalSearchService, PrincipalSearchService>(); container.Register <IMicrosoftGraphApi, MicrosoftGraphApi>(); container.Register <IAzureActiveDirectoryClientCredentialsService, AzureActiveDirectoryClientCredentialsService>("inner"); container.Register <IAzureActiveDirectoryClientCredentialsService>( (c, p) => c.Resolve <AzureActiveDirectoryCacheService>(new NamedParameterOverloads { { "innerCredentialService", c.Resolve <IAzureActiveDirectoryClientCredentialsService>("inner") } })); }
public static void ConfigureContainer(TinyIoCContainer container) { container.Register(typeof(ILogHandler), typeof(Logger.Log4NetLogger)).AsSingleton(); container.Register(typeof(IMessageRouter<IMessage>), typeof(MessageRouter)).AsSingleton(); container.RegisterMultiple<IClientLifecycleCallbackHandler>(new List<Type>() { typeof (BlyncLightManager), typeof (SkypeManager) }).AsSingleton(); container.RegisterMultiple<IBlyncLightBehaviour>(new List<Type>() { typeof (SkypeStatusResponder), typeof (BlyncLightScheduler) }); container.RegisterMultiple<ISkypeBehaviour>(new List<Type>() { typeof (CallStatusNotifier), typeof (UserStatusNotifier), typeof (OnBreakBehaviour), typeof (OnLunchBehaviour), typeof (OnCallBehaviour) }); //IBlyncLightBehaviour container.Register(typeof(SkypeStatusResponder), new SkypeStatusResponder(container.Resolve<IMessageRouter<IMessage>>())); //IClientLifecycleCallbackHandler container.Register(typeof(SkypeManager), new SkypeManager(container.Resolve<ILogHandler>(), container.Resolve<IMessageRouter<IMessage>>(), container.ResolveAll<ISkypeBehaviour>().OrderByDescending(s => s.Priority).ToList())); container.Register(typeof(BlyncLightManager), new BlyncLightManager(container.Resolve<ILogHandler>(), container.Resolve<IMessageRouter<IMessage>>(), container.ResolveAll<IBlyncLightBehaviour>().OrderByDescending(s => s.Priority).ToList())); //Client container.Register(typeof(BlyncLightForSkypeClient), new BlyncLightForSkypeClient()); }
protected override void ConfigureApplicationContainer(TinyIoCContainer container) { base.ConfigureApplicationContainer(container); container.Register<ISirenDocumentWriter<Order>, OrderWriter>(); container.Register<ISirenDocumentWriter<OrderItemViewModel>, OrderItemViewModelWriter>(); container.RegisterMultiple<ILinkGenerator>(new[] { typeof(OrderLinkGenerator) }); }
private static void RegisterStrategies(TinyIoCContainer container) { container.RegisterMultiple(typeof(IBetCalculatorStrategy), new List <Type> { typeof(NormalBetCalculatorStrategy), typeof(FreeBetSnrCalculatorStrategy), typeof(FreeBetSrCalculatorStrategy) }); }
private bool RegisterMultiple(TinyIoCContainer container, ILogger logger) { logger.WriteLine("RegisterMultiple"); container.RegisterMultiple <ITestInterface>(new Type[] { typeof(TestClassWithInterface), typeof(TestClassWithInterface2) }); var result = container.ResolveAll <ITestInterface>(); return(result.Count() == 2); }
private static void RegisterMenuCommands(TinyIoCContainer container) { var items = TypeFinder.FindTypesOf(typeof(IMenuCommand), new[] { typeof(IMenuCommand).Assembly, typeof(ContainerBuilder).Assembly }); container.RegisterMultiple(typeof(IMenuCommand), items); }
private void RegisterScenarios(TinyIoCContainer container) { var scenarios = AssemblyTypeResolver .GetAllTypesFromAppDomain() .Where(type => type.IsScenario() && !type.IsAbstract) .ToList(); container.RegisterMultiple <IScenario>(scenarios); this.Log().DebugFormat("Registered {RegisteredScenarioCount} Scenarios", scenarios.Count); }
private void RegisterScenarios(TinyIoCContainer container) { var scenarios = AssemblyTypeResolver .GetAllTypesFromAppDomain() .Where(type => type.IsScenario() && !type.IsAbstract) .ToList(); container.RegisterMultiple<IScenario>(scenarios); this.Log().DebugFormat("Registered {RegisteredScenarioCount} Scenarios", scenarios.Count); }
protected override void ConfigureApplicationContainer(TinyIoCContainer container) { base.ConfigureApplicationContainer(container); container.Register <IEquifaxRequestParser, EquifaxRequestParser>(); container.RegisterMultiple <IHandleDefaultMessages>(new[] { typeof(DefaultEquifaxMessageHandler), typeof(EquifaxPasswordResetMessageHandler) }); }
public static void ConfigureContainer(TinyIoCContainer container) { container.Register(typeof(ISkypeClient), typeof(SkypeClient)).AsSingleton(); container.Register(typeof(ILogHandler), typeof(Logger.Log4NetLogger)).AsSingleton(); container.RegisterMultiple<IClientLifecycleCallbackHandler>(new List<Type>() { typeof (TextToSpeechBehaviour) }); }
void RegisterBundlePipelineServices(TinyIoCContainer container) { container.Register( typeof(IBundlePipeline <T>), (c, p) => CreateBundlePipeline(c) ); container.RegisterMultiple( typeof(IBundlePipelineModifier <T>), getImplementationTypes(typeof(IBundlePipelineModifier <T>)) ).AsMultiInstance(); }
private ServiceLocatorProvider Configure(TinyIoCContainer container) { container.AutoRegister(new[] { GetType().Assembly }); container.Register(DefaultJwt4NetConfig.Instance); container.Register(DefaultJwt4NetConfig.Instance.ReaderSettings); container.Register(DefaultJwt4NetConfig.Instance.Issuer); container.Register(DefaultJwt4NetConfig.Instance.Issuer.Key); container.RegisterMultiple <ITokenValidationRule>(new[] { typeof(IssuerMustBeTrustedRule), typeof(SignatureMustBeValidRule), typeof(ExpiryDateMustBeInThePastRule) }); _configured = true; return(() => this); }
protected override void ConfigureApplicationContainer(TinyIoCContainer container) { base.ConfigureApplicationContainer(container); container.Register <JsonSerializer, CustomJsonSerializer>(); container.Register <ISirenDocumentWriter <SiteDetail>, HomeWriter>(); container.Register <ISirenDocumentWriter <Order>, OrderWriter>(); container.Register <ISirenDocumentWriter <OrderItemViewModel>, OrderItemViewModelWriter>(); container.RegisterMultiple <ILinkGenerator>(new[] { typeof(HomeLinkGenerator), typeof(OrderItemLinkGenerator), typeof(OrderLinkGenerator) }); }
void RegisterFileSearchServices(TinyIoCContainer container) { container.Register( typeof(IFileSearch), (c, p) => CreateFileSearch(c), HostBase.FileSearchComponentName(typeof(T)) ); container.RegisterMultiple( typeof(IFileSearchModifier <T>), getImplementationTypes(typeof(IFileSearchModifier <T>)) ).AsMultiInstance(); }
private static void RegisterItems(TinyIoCContainer container) { var type = typeof(Item); var items = TypeFinder.FindTypesOf(type, type.Assembly); items = from item in items where item.IsBrowsable() orderby item.Name select item; container.RegisterMultiple(typeof(Item), items); }
public AppBootstrapper() { Router = new RoutingState(); Kernel = new TinyIoCContainer(); // XXX: This is gross Kernel.Register <UIViewController>(new RouterUINavigationController(Router), "InitialPage"); Kernel.Register(typeof(IViewFor <iOSPlaygroundViewModel>), typeof(iOSPlaygroundViewController)); Kernel.Register <IScreen>(this); var toRegister = new Dictionary <Tuple <Type, String>, List <Type> >(); RxApp.ConfigureServiceLocator( (t, s) => s != null ? Kernel.Resolve(t, s) : Kernel.Resolve(t), (t, s) => Kernel.ResolveAll(t, true), (c, t, s) => { if (toRegister != null) { var pair = Tuple.Create(t, s); if (!toRegister.ContainsKey(pair)) { toRegister[pair] = new List <Type>(); } toRegister[pair].Add(c); return; } if (s != null) { Kernel.Register(t, c, s); } else { Kernel.Register(t, c); } }); foreach (var key in toRegister.Keys) { var val = toRegister[key].Distinct(); Kernel.RegisterMultiple(key.Item1, val); } toRegister = null; var items = Kernel.ResolveAll(typeof(ICreatesObservableForProperty), true).ToArray(); Router.Navigate.Go <iOSPlaygroundViewModel>(); }
public void RegisterInstances() { _kernel.Register <IApplicationContext, ApplicationContext>().AsSingleton(); _kernel.RegisterMultiple <IRegistry>( new List <Type> { typeof(ManagerRegistry), typeof(ServerRegistry), typeof(ClassRegistry), typeof(FactoryRegistry), typeof(AlgorithmRegistry), }); }
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { container.Register <IScrapperConfiguration, ScrapperConfiguration>(); container.Register <IHttpClient, HttpClient>(); container.Register <IScrapper, RadioScrapper>(); var type = typeof(IParser); var parserTypes = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(a => a.GetTypes()) .Where(p => type.IsAssignableFrom(p) && p.IsClass && !p.IsAbstract); container.RegisterMultiple <IParser>(parserTypes); }
protected override void ConfigureApplicationContainer(TinyIoCContainer nancyContainer) { nancyContainer.Register(_nancyModuleCatalog); // Соглашения обработки запросов должны устанавливаться явно, так как автоматический поиск соглашений в Mono/Linux не работает, // поскольку при поиске Nancy использует метод AppDomain.CurrentDomain.GetAssemblies(), который возвращает все сборки текущего // домена приложения, кроме той, который его вызывала. Ниже зарегистрированы соглашения, используемые Nancy по умолчанию. nancyContainer.RegisterMultiple <IConvention>(new[] { typeof(DefaultViewLocationConventions), typeof(DefaultStaticContentsConventions), typeof(DefaultAcceptHeaderCoercionConventions), typeof(DefaultCultureConventions) }).AsSingleton(); }
public static void ConfigureContainer(TinyIoCContainer container) { container.Register(typeof(ILogHandler), typeof(Logger.Log4NetLogger)).AsSingleton(); container.Register<InMemorySessionManager>().AsSingleton(); var sessionManager = container.Resolve<InMemorySessionManager>(); container.Register<ISessionHandler, InMemorySessionManager>(sessionManager); container.RegisterMultiple<IMessageLifecycleCallbackHandler>(new List<Type>() { typeof (SessionMessageLifecycleCallback), typeof (SpamManager) }).AsSingleton(); container.Register(typeof(TorqueMasterServer), new TorqueMasterServer(container, new IPEndPoint(IPAddress.Any, 28002))); }
private async Task ApplicationStartupAsync(TinyIoCContainer container, IPipelines pipelines) { var endpointInstance = await BusUtils.CreateBus("mskmanager.frontoffice", (config, route) => { route.RouteToEndpoint(typeof(AddDeezerUser), "mskmanager.persistence"); }); container.Register(endpointInstance); var type = typeof(IValidator); var validatorTypes = AppDomain.CurrentDomain.GetAssemblies() .Where(a => a.FullName.Contains("MskManager.Frontoffice")) .SelectMany(a => a.GetTypes()) .Where(p => type.IsAssignableFrom(p) && p.IsClass && !p.IsAbstract); container.RegisterMultiple(type, validatorTypes); }
public AppBootstrapper() { Router = new RoutingState(); Kernel = new TinyIoCContainer(); // XXX: This is gross Kernel.Register<UIViewController>(new RouterUINavigationController(Router), "InitialPage"); Kernel.Register(typeof(IViewFor<iOSPlaygroundViewModel>), typeof(iOSPlaygroundViewController)); Kernel.Register<IScreen>(this); var toRegister = new Dictionary<Tuple<Type, String>, List<Type>>(); RxApp.ConfigureServiceLocator( (t, s) => s != null ? Kernel.Resolve(t, s) : Kernel.Resolve(t), (t, s) => Kernel.ResolveAll(t, true), (c, t, s) => { if (toRegister != null) { var pair = Tuple.Create(t,s); if (!toRegister.ContainsKey(pair)) { toRegister[pair] = new List<Type>(); } toRegister[pair].Add(c); return; } if (s != null) { Kernel.Register(t, c, s); } else { Kernel.Register(t, c); } }); foreach(var key in toRegister.Keys) { var val = toRegister[key].Distinct(); Kernel.RegisterMultiple(key.Item1, val); } toRegister = null; var items = Kernel.ResolveAll(typeof(ICreatesObservableForProperty), true).ToArray(); Router.Navigate.Go<iOSPlaygroundViewModel>(); }
protected ViewModelLocator(bool isAgent) { _container = new TinyIoCContainer(); var assms = new [] { typeof(ViewModelLocator).GetTypeInfo().Assembly }; var typeinf = typeof(IToolViewModel).GetTypeInfo(); if (isAgent) { var src = typeof(ClientMainService); _container.AutoRegister(assms, t => t != src && !typeinf.IsAssignableFrom(t.GetTypeInfo())); // skip the client service in agent mode Mode = AppMode.Agent; } else { var arc = typeof(AgentMainService); _container.AutoRegister(assms, t => t != arc && !typeinf.IsAssignableFrom(t.GetTypeInfo())); // skip the agent service in client mode Mode = AppMode.Client; } _container.Register <IViewModelLocator>(this); var tools = new [] { //typeof(SampleToolViewModel), typeof(TypesOfInsuranceViewModel), typeof(DividendInterestRatesViewModel), typeof(BasicInformationToolViewModel), typeof(LifetimeEconomicValueViewModel), //typeof(AnotherSampleToolViewModel), }; _container.RegisterMultiple <IToolViewModel>(tools).AsMultiInstance(); InitializeTypes(); _container.Resolve <INavigationService>().Initialize(); }
protected virtual void RegisterMultiple(Type type, TinyIoCContainer container, IEnumerable<Func<Assembly, bool>> ignoredAssemblies) { foreach (var group in AppDomain.CurrentDomain.GetAssemblies() .Where(a => !ignoredAssemblies.Any(ia => ia(a))) .SelectMany(t => t.GetTypes()) .Where(t => t.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == type) && t.IsClass) .ToList().GroupBy(implType => implType.GetInterfaces().Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == type), implType => implType)) { foreach (var item in group.Key) { container.RegisterMultiple(item, group); } } }
protected virtual void BindServices(CompositionBatch batch) { try { _tinyIoCContainer = new TinyIoCContainer(); var eventAggregator = new EventAggregator(); // Defaults batch.AddExportedValue<IWindowManager>(new WindowManager()); batch.AddExportedValue<IEventAggregator>(eventAggregator); // framework and infrastructure _tinyIoCContainer.Register<IEventAggregator>(eventAggregator); // _tinyIoCContainer.Register<IServiceLocator>(new TinyServiceLocator(_container)); _tinyIoCContainer.RegisterMultiple<IMessageEventSubscriber>(new[] {typeof (EventMessageListener)}) .AsSingleton(); // register other implementations DependencyFactory.Configure(_tinyIoCContainer); // Export IoC registrations batch.AddExportedValue(_tinyIoCContainer.Resolve<IRestartableMessageListener>()); batch.AddExportedValue(Container); } catch (Exception e) { Log.Error(e, "Error on Bootstrapper BindServices: {CompositionBatch}", batch); } }
public void RegisterMultiple <RegisterType>(IEnumerable <Type> implementationTypes) { _container.RegisterMultiple <RegisterType>(implementationTypes); }
protected override void Configure(TinyIoCContainer container) { // Register Mappings: container.RegisterMultiple<IMap>(new [] { typeof(SampleEntityMapping) }); // Register DAO: container.Register<SampleEntityDao>(); }
/// <summary> /// 注册 /// </summary> public static void RegisterTypes <TServiceType>() where TServiceType : class { var list = GetTypes().Where(t => typeof(TServiceType).IsAssignableFrom(t) && t.IsClass && !t.IsAbstract && !t.IsInterface); _container.RegisterMultiple(typeof(TServiceType), list); }
void RegisterStartUpTasks() { container.RegisterMultiple(typeof(IStartUpTask), GetStartUpTaskTypes()); }
public void RegisterAllAsSingleton(Type registrationType, IEnumerable <Type> implementationList) { _container.RegisterMultiple(registrationType, implementationList).AsSingleton(); }
/// <summary> /// Register multiple implementations of a type. /// </summary> /// <typeparam name="TRegisterType">Type that each implementation implements</typeparam> /// <param name="container">TinyIoC container to register with.</param> /// <param name="assemblies"> /// Assembly collection containing defined types to be retrieved. /// Defaults to all current domain assemblies. /// </param> /// <returns>MultiRegisterOptions for the fluent API.</returns> public static TinyIoCContainer.MultiRegisterOptions RegisterMultiple <TRegisterType>(this TinyIoCContainer container, params Assembly[] assemblies) where TRegisterType : class { return(container.RegisterMultiple <TRegisterType>((assemblies ?? AppDomain.CurrentDomain.GetAssemblies()).GetConcreteTypes <TRegisterType>())); }