public void Bind(IConfigurator resolver) { resolver.Bind <IModuleConfigTest>().To <ModuleConfigTest>(); resolver.Bind <IModuleConfigTest>().To <ModuleConfigTest2>("test2"); resolver.Bind <IModuleConfigTest>().To <ModuleConfigTest2>(ConsoleKey.Add); resolver.Bind <IModuleConfigTest>().To <ModuleConfigTest>(); //var instances = Resolver.GetAllInstances<IModuleConfigTest>(); ////resolver.Bind<IModuleConfigTest>().ToInstance(new ModuleConfigTest3(instances), "test"); resolver.Bind <IModuleConfigTest>().ToConstructor(() => new ModuleConfigTest3(Resolver.GetAllInstancesNamed <IModuleConfigTest>("test").Values), "test"); }
partial void LoadConfiguration(IConfigurator configuration) { configuration.Bind <IDummy>().To <Dummy>().SetTransientScope(); configuration.Bind <IDummyService>() .ToConstructor(s => new ServiceLocator(s).CreateRestClient <IDummyService>("")) .SetRequestResponseScope(); configuration.Bind <IHelper>().To <Helper>().SetRequestResponseScope(); //configuration.BindWebApiController<IProfileService>() // .ToConstructor(() => CreateProxy<IProfileService>("profile.service.url")); //configuration.Bind<IProfileService>().ToConstructor(() => CreateProxy<IProfileService>("profile.service.url")); }
public void Bind(IConfigurator configuration) { configuration.AddEntityBinding((type, type1) => { configuration.Bind(type).To(type1).SetTransientScope(); }) .Bind <IGremlinLanguageConnector>().To <Class1>().SetTransientScope(); }
public void Bind(IConfigurator configuration) { var azureServiceTokenProvider = new AzureServiceTokenProvider(); var keyVaultClient = new KeyVaultClient(async(authority, resource, scope) => await azureServiceTokenProvider.GetAccessTokenAsync(resource)); var cosmosDbAccount = keyVaultClient.GetSecretAsync("https://stardust-test-vault.vault.azure.net/", "cosmosAccountName").Result; var cosmosDbKey = keyVaultClient .GetSecretAsync("https://stardust-test-vault.vault.azure.net/", "cosmosAccountKey").Result; configuration.AddEntityBinding((type, type1) => { configuration.Bind(type).To(type1).SetTransientScope(); }) .Bind <IGremlinLanguageConnector>() .ToConstructor(s => new GremlinNetLanguageConnector($"{cosmosDbAccount.Value}.gremlin.cosmosdb.azure.com", "graphTest", "services", cosmosDbKey.Value)); GremlinFactory.SetActivatorFactory(() => new GremlinNetLanguageConnector($"{cosmosDbAccount.Value}.gremlin.cosmosdb.azure.com", "graphTest", "services", cosmosDbKey.Value)); ConfigurationManagerHelper.SetValueOnKey("cosmosDbAccount", cosmosDbAccount.Value); ConfigurationManagerHelper.SetValueOnKey("cosmosDbKey", cosmosDbKey.Value); }
public void Bind(IConfigurator Resolver) { Resolver.Bind <IDummyService>().To <DummyServiceImplementation>().SetRequestResponseScope(); }
private void ConfigureIoc(IConfigurator configuration) { configuration.Bind <ITestService>().To <TestService>().SetRequestResponseScope(); configuration.Bind <ITestService>().ToConstructor(s => new TestService2(s), "test") .SetRequestResponseScope(); }
public void Bind(IConfigurator configuration) { configuration.Bind <IGremlinLanguageConnector>().To <Class1>().SetTransientScope(); //configuration.Bind<Vertices>().ToSelf(); }
public static IConfigurator ResolveAssembly(this IConfigurator self, bool onlyInterfacesOrAbstracts, Assembly assembly, Action <IScopeContext> scopeHandler = null) { if (scopeHandler == null) { scopeHandler = a => { a.SetTransientScope(); } } ; foreach (var definedType in assembly.DefinedTypes) { if (onlyInterfacesOrAbstracts && !definedType.IsConcreteType()) { continue; } var name = definedType.GetAttribute <ImplementationKeyAttribute>() != null?definedType.GetAttribute <ImplementationKeyAttribute>().Name : TypeLocatorNames.DefaultName; var implementations = FindImplementations(definedType); foreach (var implementation in implementations) { scopeHandler(definedType.IsGenericTypeDefinition ? self.BindAsGeneric(definedType).To(implementation, name) : self.Bind(definedType).To(definedType, name)); } } return(self); }
private void BindWebActivator(IConfigurator configuration) { var c = configuration as IInternalConfigurator; var di = c?.Items["resolver"] as IDependencyResolver; configuration.Bind <IProxyFactory>().To <ProxyFactoryImplementation>().SetRequestResponseScope(); configuration.Bind <IServiceLocator>().To <ServiceLocator>().SetRequestResponseScope(); configuration.Bind <IServiceProvider>().To <ServiceLocator>().SetRequestResponseScope(); configuration.UnBind <IHttpActionInvoker>().AllAndBind().To <Invoker>().SetTransientScope(); configuration.Bind <IControllerFactory>().To <StardustControllerFactory>().SetSingletonScope(); configuration.Bind <IHttpControllerActivator>().To <StardustControllerActivator>().SetSingletonScope(); configuration.Bind <IActionInvoker>().To <ControllerInvoker>().SetRequestResponseScope(); configuration.Bind <IControllerActivator>().To <StardustControllerActivator>().SetSingletonScope(); configuration.Bind <IServiceParameterResolver>().To <CustomResolver>().SetSingletonScope(); configuration.Bind(typeof(ILogging)).To(LoggingType).SetRequestResponseScope(); GlobalConfiguration.Configuration.DependencyResolver = new StardustDependencyResolver(); DependencyResolver.SetResolver(new StardustDependencyResolver()); configuration.Bind <IProxyFactory>().To <ProxyFactoryImplementation>().SetRequestResponseScope(); configuration.Bind <HttpContextAccessor>().To <HttpContextAccessor>().SetRequestResponseScope(); }
public static IWebApiBindContext <T> BindWebApiController <T>(this IConfigurator configuration) { var resolver = (configuration as IInternalConfigurator)?.Items["resolver"] as IDependencyResolver; return(new BindContext <T>(configuration.Bind <T>(), resolver)); }
public void Bind(IConfigurator resolver) { resolver.Bind<IModuleConfigTest>().To<ModuleConfigTest>(); resolver.Bind<IModuleConfigTest>().To<ModuleConfigTest2>("test2"); resolver.Bind<IModuleConfigTest>().To<ModuleConfigTest2>(ConsoleKey.Add); }