RegisterChatMessagesPermissionValidator(IDependencyRegistrar registrar) { return(registrar.Register <ChatMessagesPermissionValidator>() .AsSelf() .As <IChatMessagesPermissionValidator <ChatInfo, ChatUser, List <ChatMessage>, ChatMessage, ChatMessageInfo, TextMessage, QuoteMessage, List <MessageAttachment>, MessageAttachment, List <ChatRefMessage>, ChatRefMessage, List <ContactMessage>, ContactMessage, MessageFilter, PagedResult <List <ChatMessage>, ChatMessage>, PagingOptions> >() .AsTransient()); }
public static void RegisterPluginDataContext <T>(this IDependencyRegistrar dependencyRegistrar, ContainerBuilder builder, string contextName, string filePath = null, bool reloadSettings = false) where T : IDbContext { //data layer var dataSettingsManager = new DataAyarlarıYönetici(); var dataProviderSettings = dataSettingsManager.AyarlarıYükle(filePath, reloadSettings); if (dataProviderSettings != null && dataProviderSettings.Geçerli()) { //register named context builder.Register(c => (IDbContext)Activator.CreateInstance(typeof(T), new object[] { dataProviderSettings.DataConnectionString })) .Named <IDbContext>(contextName) .InstancePerLifetimeScope(); builder.Register(c => (T)Activator.CreateInstance(typeof(T), new object[] { dataProviderSettings.DataConnectionString })) .InstancePerLifetimeScope(); } else { //register named context builder.Register(c => (T)Activator.CreateInstance(typeof(T), new object[] { c.Resolve <DataAyarları>().DataConnectionString })) .Named <IDbContext>(contextName) .InstancePerLifetimeScope(); builder.Register(c => (T)Activator.CreateInstance(typeof(T), new object[] { c.Resolve <DataAyarları>().DataConnectionString })) .InstancePerLifetimeScope(); } }
RegisterChatParticipantsPermissionValidator(IDependencyRegistrar registrar) { return(registrar.Register <ChatParticipantsPermissionValidator>() .AsSelf() .As <IChatParticipantsPermissionValidator <List <ParticipationCandidate>, ParticipationCandidate> >() .AsTransient()); }
protected override void RegisterViewModels(IDependencyRegistrar dependencyRegistrar) { dependencyRegistrar.Singleton <IShellViewModel, ShellViewModel>(); dependencyRegistrar.Singleton <IMainViewModel, MainViewModel>(); dependencyRegistrar.Singleton <IDashboardViewModel, DashboardViewModel>(); dependencyRegistrar.Singleton <IExercisesViewModel, ExercisesViewModel>(); }
public Container() { var container = DefaultContainer(); _resolver = container; _registrar = container; }
/// <summary> /// Register custom DataContext for a plugin /// </summary> /// <typeparam name="T">Class implementing IDbContext</typeparam> /// <param name="dependencyRegistrar">Dependency registrar</param> /// <param name="builder">Builder</param> /// <param name="contextName">Context name</param> public static void RegisterPluginDataContext <T>(this IDependencyRegistrar dependencyRegistrar, ContainerBuilder builder, string contextName) where T : IDbContext { //data layer //var dataSettingsManager = new DataSettingsManager(); //var dataProviderSettings = dataSettingsManager.LoadSettings(); //if (dataProviderSettings != null && dataProviderSettings.IsValid()) //{ // //register named context // builder.Register(c => (IDbContext)Activator.CreateInstance(typeof(T), new object[] { dataProviderSettings.DataConnectionString })) // .Named<IDbContext>(contextName) // .InstancePerLifetimeScope(); // builder.Register(c => (T)Activator.CreateInstance(typeof(T), new object[] { dataProviderSettings.DataConnectionString })) // .InstancePerLifetimeScope(); //} //else //{ //register named context builder.Register(c => (T)Activator.CreateInstance(typeof(T), new object[] { ConfigurationManager.ConnectionStrings["DbContextManager"].ConnectionString })) .Named <IDbContext>(contextName) .InstancePerLifetimeScope(); builder.Register(c => (T)Activator.CreateInstance(typeof(T), new object[] { ConfigurationManager.ConnectionStrings["DbContextManager"].ConnectionString })) .InstancePerLifetimeScope(); //} }
protected override void RegisterViewModels(IDependencyRegistrar dependencyRegistrar) { if (_registerRootViewModel) { dependencyRegistrar.Singleton <IRootViewModel, RootViewModel>(); } }
public DependencyContainer(IUnityContainer unityContainer) { unityContainer.ThrowIfNull(); _unityContainer = unityContainer; _registrar = new DependencyRegistrar(unityContainer); }
public BootstrapperBaseTests() { DependencyContainerCreation dependencyContainerCreation = DependencyContainerFactory.Create(); _dependencyRegistrar = dependencyContainerCreation.Registrar; _dependencyRetriever = dependencyContainerCreation.Retriever; }
protected BootstrapperBase(IDependencyRegistrar dependencyRegistrar, IDependencyRetriever dependencyRetriever) { _dependencyRegistrar = dependencyRegistrar; _dependencyRetriever = dependencyRetriever; Initialize(); }
/// <summary> /// Register custom DataContext for a plugin /// </summary> /// <typeparam name="T">Class implementing IDbContext</typeparam> /// <param name="dependencyRegistrar">Dependency registrar</param> /// <param name="builder">Builder</param> /// <param name="contextName">Context name</param> public static void RegisterPluginDataContext <T>(this IDependencyRegistrar dependencyRegistrar, ContainerBuilder builder, string contextName) where T : IDbContext { //data layer var dataSettingsManager = new DataSettingsManager(); var dataProviderSettings = dataSettingsManager.LoadSettings(); if (dataProviderSettings != null && dataProviderSettings.IsValid()) { //register named context builder.Register(c => (IDbContext)Activator.CreateInstance(typeof(T), new object[] { dataProviderSettings.DataConnectionString })) .Named <IDbContext>(contextName) .InstancePerLifetimeScope(); builder.Register(c => (T)Activator.CreateInstance(typeof(T), new object[] { dataProviderSettings.DataConnectionString })) .InstancePerLifetimeScope(); } else { //register named context builder.Register(c => (T)Activator.CreateInstance(typeof(T), new object[] { c.Resolve <DataSettings>().DataConnectionString })) .Named <IDbContext>(contextName) .InstancePerLifetimeScope(); builder.Register(c => (T)Activator.CreateInstance(typeof(T), new object[] { c.Resolve <DataSettings>().DataConnectionString })) .InstancePerLifetimeScope(); } }
RegisterDotChat(IDependencyRegistrar registrar) { return(registrar.Register <DotChatFacade>() .AsSelf() .As <IDotChat <PersonalizedChatsSummary, List <PersonalizedChat>, PersonalizedChat, Chat, ChatInfo, ParticipationCandidates, List <ParticipationCandidate>, ParticipationCandidate, List <ChatParticipant>, ChatParticipant, ChatUser, List <ChatMessage>, ChatMessage, ChatMessageInfo, TextMessage, QuoteMessage, List <MessageAttachment>, MessageAttachment, List <ChatRefMessage>, ChatRefMessage, List <ContactMessage>, ContactMessage, ChatFilter <ChatUserFilter, MessageFilter>, ChatUserFilter, MessageFilter, PagedResult <List <PersonalizedChat>, PersonalizedChat>, PagedResult <List <ChatMessage>, ChatMessage>, PagingOptions> >() .As <IDotChat>() .AsTransient()); }
public void Initialize(IDependencyRegistrar registrar) { registrar.RegisterType <ITestProjectContext, TestProjectEntities>(); registrar.RegisterType <IUserRepository, UserRepository>(); registrar.RegisterType <IUserSessionRepository, UserSessionRepository>(); registrar.RegisterType <IUserRoleRepository, UserRoleRepository>(); registrar.RegisterType <IRoleRepository, RoleRepository>(); }
/// <summary> /// 添加额外的注册(这个操作要尽量早执行) /// </summary> /// <param name="reg"></param> public static void AddExtraRegistrar(IDependencyRegistrar reg) { if (context != null) { throw new Exception("依赖注入容器已经生成,请在生成前注册额外依赖"); } ExtraRegistrars.Add(reg); }
internal ServiceFactoryRegistrar(IDependencyRegistrar dependencyRegistrar, IRetrievalStrategyFactory retrievalStrategyFactory, IRetrievalStrategyStore retrievalStrategyStore) { _dependencyRegistrar = dependencyRegistrar; _retrievalStrategyFactory = retrievalStrategyFactory; _retrievalStrategyStore = retrievalStrategyStore; }
protected override void RegisterViewModels(IDependencyRegistrar dependencyRegistrar) { dependencyRegistrar.Singleton <IShellViewModel, ShellViewModel>(); dependencyRegistrar.Singleton <IMainViewModel, MainViewModel>(); dependencyRegistrar.Singleton <IChampionPickViewModel, ChampionPickViewModel>(); dependencyRegistrar.Singleton <IRoleDisplayViewModel, RoleDisplayViewModel>(); dependencyRegistrar.Singleton <IGameTrackViewModel, GameTrackViewModel>(); }
internal Bootstrapper(IDependencyRegistrar dependencyRegistrar, IDependencyRetriever dependencyRetriever, bool registerRootViewModel = true) : base(dependencyRegistrar, dependencyRetriever) { _registerRootViewModel = registerRootViewModel; Configure(); }
protected BootstrapperBase() { DependencyContainerCreation dependencyContainerCreation = DependencyContainerFactory.Create(); _dependencyRegistrar = dependencyContainerCreation.Registrar; _dependencyRetriever = dependencyContainerCreation.Retriever; Initialize(); }
/// <summary> /// 添加额外的注册(这个操作要尽量早执行) /// </summary> /// <param name="reg"></param> public IocContext AddExtraRegistrar(IDependencyRegistrar reg) { if (this._lazy.IsValueCreated) { throw new Exception("依赖注入容器已经生成,请在生成前注册额外依赖"); } this.ExtraRegistrars.Add(reg); return(this); }
public ServiceFactoryTests() { DependencyContainerCreation dependencyContainerCreation = DependencyContainerFactory.Create(); _dependencyRegistrar = dependencyContainerCreation.Registrar; ServiceFactoryCreation serviceFactoryCreation = ServiceFactoryFactory.Create(dependencyContainerCreation.Registrar, dependencyContainerCreation.Retriever); _serviceFactoryRegistrar = serviceFactoryCreation.Registrar; _serviceFactory = serviceFactoryCreation.Factory; }
public override void Register(IDependencyRegistrar registrar, bool rootModule) { registrar.Register(_bus) .AsSelf() .AsSingleton() .Build(); registrar.Register(_store) .AsSelf() .AsSingleton() .Build(); base.Register(registrar, rootModule); }
protected override void RegisterServices(IDependencyRegistrar dependencyRegistrar) { dependencyRegistrar.Singleton <IEventAggregator, EventAggregator>(); dependencyRegistrar.Singleton <IAppDataService, AppDataService>(); dependencyRegistrar.Singleton <IClipboardService, ClipboardService>(); dependencyRegistrar.Singleton <IDataService, DataService>(); dependencyRegistrar.Singleton <IFileSystemService, FileSystemService>(); dependencyRegistrar.Singleton <IReferencingService, ReferencingService>(); dependencyRegistrar.Singleton <ISettingsService, SettingsService>(); dependencyRegistrar.Singleton <IWebService, WebService>(); }
/// <summary> /// Register custom DataContext for a plugin /// </summary> /// <typeparam name="T">Class implementing IDbContext</typeparam> /// <param name="dependencyRegistrar">Dependency registrar</param> /// <param name="builder">Builder</param> /// <param name="contextName">Context name</param> public static void RegisterPluginDataContext <T>(this IDependencyRegistrar dependencyRegistrar, ContainerBuilder builder, string contextName) where T : IDbContext { // Override required repository with your custom context builder .RegisterType <EfRepository <Image360> >() .As <IRepository <Image360> >() .WithParameter(ResolvedParameter.ForNamed <IDbContext>("CONTEXT_NAME")) .InstancePerLifetimeScope(); // Override required repository with your custom context builder .RegisterType <EfRepository <CarMakeBulkImages> >() .As <IRepository <CarMakeBulkImages> >() .WithParameter(ResolvedParameter.ForNamed <IDbContext>("CONTEXT_NAME")) .InstancePerLifetimeScope(); // Override required repository with your custom context builder .RegisterType <EfRepository <ExtraPictureCarMake> >() .As <IRepository <ExtraPictureCarMake> >() .WithParameter(ResolvedParameter.ForNamed <IDbContext>("CONTEXT_NAME")) .InstancePerLifetimeScope(); //data layer var dataSettingsManager = new DataSettingsManager(); var dataProviderSettings = dataSettingsManager.LoadSettings(); if (dataProviderSettings != null && dataProviderSettings.IsValid()) { //register named context builder.Register(c => (IDbContext)Activator.CreateInstance(typeof(T), new object[] { dataProviderSettings.DataConnectionString })) .Named <IDbContext>(contextName) .InstancePerLifetimeScope(); builder.Register(c => (T)Activator.CreateInstance(typeof(T), new object[] { dataProviderSettings.DataConnectionString })) .InstancePerLifetimeScope(); } else { //register named context builder.Register(c => (T)Activator.CreateInstance(typeof(T), new object[] { c.Resolve <DataSettings>().DataConnectionString })) .Named <IDbContext>(contextName) .InstancePerLifetimeScope(); builder.Register(c => (T)Activator.CreateInstance(typeof(T), new object[] { c.Resolve <DataSettings>().DataConnectionString })) .InstancePerLifetimeScope(); } }
public static ServiceFactoryCreation Create(IDependencyRegistrar dependencyRegistrar, IDependencyRetriever dependencyRetriever) { RetrievalStrategyStore retrievalStrategyStore = new RetrievalStrategyStore(); return(new ServiceFactoryCreation(new ServiceFactoryRegistrar(dependencyRegistrar, new RetrievalStrategyFactory(dependencyRetriever, new ConstructorMapFactory(new ConstructorQueryProvider(new ConstructorFactory())), new ArgumentBuilderFactory(dependencyRetriever), new ObjectBuilderFactory() ), retrievalStrategyStore ), new ServiceFactory(retrievalStrategyStore) )); }
protected override void RegisterViewModels(IDependencyRegistrar dependencyRegistrar) { dependencyRegistrar.Singleton <IShellViewModel, ShellViewModel>(); dependencyRegistrar.Singleton <IMainViewModel, MainViewModel>(); dependencyRegistrar.Singleton <ISettingsViewModel, SettingsViewModel>(); dependencyRegistrar.Singleton <IFileSystemViewModel, FileSystemViewModel>(); dependencyRegistrar.PerRequest <IFolderViewModel, FolderViewModel>(); dependencyRegistrar.PerRequest <IFileViewModel, FileViewModel>(); dependencyRegistrar.Singleton <IReferenceGeneratorViewModel, ReferenceGeneratorViewModel>(); dependencyRegistrar.Singleton <IReferencesViewModel, ReferencesViewModel>(); dependencyRegistrar.PerRequest <IReferenceViewModel, ReferenceViewModel>(); }
public virtual void Register(IDependencyRegistrar registrar, bool rootModule) { if (ChatServiceModule != null) { ChatServiceModule.Register(registrar, false); } RegisterChatNotificationsConfiguration(registrar).Build(); RegisterChatsNotificationBuilder(registrar).Build(); RegisterChatParticipantsNotificationBuilder(registrar).Build(); RegisterChatMessagesNotificationBuilder(registrar).Build(); RegisterChatNotifier(registrar).Build(); RegisterChatParticipantNotifier(registrar).Build(); RegisterChatMessageNotifier(registrar).Build(); RegisterNotificationRouteService(registrar).Build(); RegisterNotificationSender(registrar).Build(); }
protected override void RegisterDependencies(CopterConfig config) { ContainerBuilder builder = new ContainerBuilder(); IContainer container = builder.Build(); ContainerManager = new WebApiContainerManager(container); //we create new instance of ContainerBuilder //because Build() or Update() method can only be called once on a ContainerBuilder. builder = new ContainerBuilder(); ITypeFinder typeFinder = new WebTypeFinder(); if (config != null) { builder.RegisterInstance(config).As <CopterConfig>().SingleInstance(); } builder.RegisterInstance(this).As <IEngine>().SingleInstance(); builder.RegisterInstance(typeFinder).As <ITypeFinder>().SingleInstance(); IEnumerable <Type> dependencyTypes = typeFinder.FindClassesOfType <IDependencyRegistrar>(); List <IDependencyRegistrar> dependencies = new List <IDependencyRegistrar>(); foreach (Type type in dependencyTypes) { IDependencyRegistrar item = (IDependencyRegistrar)Activator.CreateInstance(type); dependencies.Add(item); } dependencies = dependencies.AsQueryable().OrderBy(x => x.Order).ToList(); foreach (IDependencyRegistrar dependency in dependencies) { dependency.Register(builder, typeFinder, config); } builder.Update(container); // 注册到 webapi 容器 HttpConfiguration configuration = GlobalConfiguration.Configuration; IDependencyResolver resolver = new AutofacWebApiDependencyResolver(ContainerManager.Container); configuration.DependencyResolver = resolver; }
public virtual void Register(IDependencyRegistrar registrar, bool rootModule) { if (ChatServiceModule != null) { ChatServiceModule.Register(registrar, false); } RegisterChatWorkersConfiguration(registrar).Build(); RegisterChatMessageTimestampGenerator(registrar).Build(); RegisterChatMessageIndexGenerator(registrar).Build(); RegisterSystemMessagesBuilder(registrar).Build(); RegisterChatStore(registrar).Build(); RegisterChatParticipantStore(registrar).Build(); RegisterChatMessageStore(registrar).Build(); RegisterChatsWorker(registrar).Build(); RegisterChatParticipantsWorker(registrar).Build(); RegisterChatMessagesWorker(registrar).Build(); RegisterChatMessageIndexationWorker(registrar).Build(); RegisterChatSystemMessagesWorker(registrar).Build(); }
internal static void RegisterAllTypesOf <TService>(this IDependencyRegistrar dependencyRegistrar, Assembly assembly, Func <Type, bool> matchFilter = null, string key = null) { Type serviceType = typeof(TService); bool IsMatchNoFilter(Type type) { return(serviceType.IsAssignableFrom(type) && !type.IsAbstract); } bool IsMatchWithFilter(Type type) { return(IsMatchNoFilter(type) && matchFilter(type)); } Type[] assemblyTypes = assembly.GetTypes(); IEnumerable <Type> matchingAssemblyTypes = matchFilter == null?assemblyTypes.Where(IsMatchNoFilter) : assemblyTypes.Where(IsMatchWithFilter); foreach (Type type in matchingAssemblyTypes) { dependencyRegistrar.RegisterSingleton(serviceType, type, key); } }
public virtual void Register(IDependencyRegistrar registrar, bool rootModule) { RegisterDotChatConfiguration(registrar).Build(); RegisterChatCommandSender(registrar).Build(); RegisterChatEventPublisher(registrar).Build(); RegisterChatsCommandBuilder(registrar).Build(); RegisterChatParticipantsCommandBuilder(registrar).Build(); RegisterChatMessagesCommandBuilder(registrar).Build(); RegisterChatsEventBuilder(registrar).Build(); RegisterChatParticipantsEventBuilder(registrar).Build(); RegisterChatMessagesEventBuilder(registrar).Build(); RegisterReadChatStore(registrar).Build(); RegisterReadChatMessageStore(registrar).Build(); RegisterReadChatParticipantStore(registrar).Build(); RegisterReadUserStore(registrar).Build(); RegisterChatsService(registrar).Build(); RegisterChatParticipantsService(registrar).Build(); RegisterChatMessagesService(registrar).Build(); RegisterDotChat(registrar).Build(); RegisterChatsPermissionValidator(registrar).Build(); RegisterChatParticipantsPermissionValidator(registrar).Build(); RegisterChatMessagesPermissionValidator(registrar).Build(); }
public Bootstrapper(IDependencyRegistrar dependencyRegistrar, ILogger logger) { DisposableTasks = new List<IDisposable>(); _logger = logger; _dependencyRegistrar = dependencyRegistrar; }