public static void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { foreach (var entityType in dbContextType.GetEntityTypes()) { foreach (var interfaceType in entityType.GetInterfaces()) { if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEntity<>)) { var primaryKeyType = interfaceType.GenericTypeArguments[0]; if (primaryKeyType == typeof(Guid)) { var genericRepositoryType = typeof(IRepository<>).MakeGenericType(entityType); if (!iocManager.IsRegistered(genericRepositoryType)) { iocManager.Register( genericRepositoryType, typeof(EfRepositoryBase<,>).MakeGenericType(dbContextType, entityType), DependencyLifeStyle.Transient ); } } var genericRepositoryTypeWithPrimaryKey = typeof(IRepository<,>).MakeGenericType(entityType, primaryKeyType); if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) { iocManager.Register( genericRepositoryTypeWithPrimaryKey, typeof(EfRepositoryBase<,,>).MakeGenericType(dbContextType, entityType, primaryKeyType), DependencyLifeStyle.Transient ); } } } } }
public static void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { foreach (var entityType in dbContextType.GetEntityTypes()) { foreach (var interfaceType in entityType.GetInterfaces()) { if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEntity <>)) { var primaryKeyType = interfaceType.GenericTypeArguments[0]; if (primaryKeyType == typeof(int)) { var genericRepositoryType = typeof(IRepository <>).MakeGenericType(entityType); if (!iocManager.IsRegistered(genericRepositoryType)) { iocManager.Register( genericRepositoryType, typeof(EfRepositoryBase <,>).MakeGenericType(dbContextType, entityType), DependencyLifeStyle.Transient ); } } var genericRepositoryTypeWithPrimaryKey = typeof(IRepository <,>).MakeGenericType(entityType, primaryKeyType); if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) { iocManager.Register( genericRepositoryTypeWithPrimaryKey, typeof(EfRepositoryBase <, ,>).MakeGenericType(dbContextType, entityType, primaryKeyType), DependencyLifeStyle.Transient ); } } } } }
public void Register <T>() { if (!_iocManager.IsRegistered(typeof(T))) { _iocManager.Register(typeof(T)); } }
public static void RegisterDbContext(Type dbContextType, IIocManager iocManager) { foreach (var entityType in EntityFrameworkHelper.GetEntityTypesInDbContext(dbContextType)) { foreach (var interfaceType in entityType.GetInterfaces()) { if (interfaceType == typeof(IEntity)) { iocManager.Register( typeof(IRepository <>).MakeGenericType(entityType), typeof(EfRepositoryBase <,>).MakeGenericType(dbContextType, entityType), DependencyLifeStyle.Transient ); } else if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEntity <>)) { var primaryKeyType = interfaceType.GenericTypeArguments[0]; iocManager.Register( typeof(IRepository <,>).MakeGenericType(entityType, primaryKeyType), typeof(EfRepositoryBase <, ,>).MakeGenericType(dbContextType, entityType, primaryKeyType), DependencyLifeStyle.Transient ); } } } }
public static void RegisterGenericRepositories <TTenantId, TUserId>(Type dbContextType, Type[] entities, IIocManager iocManager) where TTenantId : struct where TUserId : struct { var autoRepositoryAttr = dbContextType.GetSingleAttributeOrNull <AutoRepositoryTypesAttribute>(); if (autoRepositoryAttr == null) { autoRepositoryAttr = AutoRepositoryTypesAttribute.Default; } foreach (var entityType in entities) { var interfaces = entityType.GetInterfaces(); foreach (var interfaceType in interfaces) { if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEntity <>)) { var primaryKeyType = interfaceType.GenericTypeArguments[0]; if (primaryKeyType.Name == "TPrimaryKey" || string.IsNullOrEmpty(primaryKeyType.FullName)) { continue; } if (primaryKeyType == typeof(int)) { var genericRepositoryType = autoRepositoryAttr.RepositoryInterface.MakeGenericType(entityType); if (!iocManager.IsRegistered(genericRepositoryType)) { var implType = GetMakedGenericType <TTenantId, TUserId>(false, iocManager, autoRepositoryAttr, dbContextType, entityType, primaryKeyType); iocManager.Register( genericRepositoryType, implType, DependencyLifeStyle.Transient ); } } var genericRepositoryTypeWithPrimaryKey = autoRepositoryAttr.RepositoryInterfaceWithPrimaryKey.MakeGenericType(entityType, primaryKeyType); if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) { var implType = GetMakedGenericType <TTenantId, TUserId>(true, iocManager, autoRepositoryAttr, dbContextType, entityType, primaryKeyType); iocManager.Register( genericRepositoryTypeWithPrimaryKey, implType, DependencyLifeStyle.Transient ); } } } } }
public static void InitalizeIocRegistrations(IIocManager ioc) { var thisAssembly = typeof(ResponsibleSystemApplicationModule).GetAssembly(); ioc.RegisterAssemblyByConvention(thisAssembly); ioc.Register <ISessionService, SessionService>(); ioc.Register <HttpClient, HttpClient>(DependencyLifeStyle.Transient); ioc.Register <ICryptoService, CryptoService>(); // TODO: sprawdzić czy nie jest zbędne }
public void register_asm_can_resolve_ICommandInvoker() { ioc.RegisterAssemblyAsInterfaces(asm); Mock <IScheduler> moq = new Mock <IScheduler>(); ioc.Register <IScheduler>(moq.Object);// 依赖于IScheduler,由于没有启动ISchedule,则不会有,故mock一个。 var cmdInvoker = ioc.Resolve <ICommandInvoker>(); Assert.IsNotNull(cmdInvoker); }
public static void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { //获取已经标记的 "AutoRepositoryTypesAttribute" 属性 var autoRepositoryAttr = dbContextType.GetSingleAttributeOrNull<AutoRepositoryTypesAttribute>(); //没有标记"AutoRepositoryTypesAttribute"属性的"DbContext"采用默认AutoRepositoryTypesAttribute属性 if (autoRepositoryAttr == null) { autoRepositoryAttr = AutoRepositoryTypesAttribute.Default; } //获取DbSet或者IDbSet属性 foreach (var entityType in dbContextType.GetEntityTypes()) { foreach (var interfaceType in entityType.GetInterfaces()) { if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEntity<>)) { var primaryKeyType = interfaceType.GenericTypeArguments[0]; if (primaryKeyType == typeof(int)) { var genericRepositoryType = autoRepositoryAttr.RepositoryInterface.MakeGenericType(entityType); if (!iocManager.IsRegistered(genericRepositoryType)) { var implType = autoRepositoryAttr.RepositoryImplementation.GetGenericArguments().Length == 1 ? autoRepositoryAttr.RepositoryImplementation.MakeGenericType(entityType) : autoRepositoryAttr.RepositoryImplementation.MakeGenericType(dbContextType, entityType); iocManager.Register( genericRepositoryType, implType, DependencyLifeStyle.Transient ); } } var genericRepositoryTypeWithPrimaryKey = autoRepositoryAttr.RepositoryInterfaceWithPrimaryKey.MakeGenericType(entityType, primaryKeyType); if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) { var implType = autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.GetGenericArguments().Length == 2 ? autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(entityType, primaryKeyType) : autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(dbContextType, entityType, primaryKeyType); iocManager.Register( genericRepositoryTypeWithPrimaryKey, implType, DependencyLifeStyle.Transient ); } } } } }
public static void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { var autoRepositoryAttr = dbContextType.GetSingleAttributeOrNull <AutoRepositoryTypesAttribute>(); if (autoRepositoryAttr == null) { autoRepositoryAttr = AutoRepositoryTypesAttribute.Default; } foreach (var entityType in dbContextType.GetEntityTypes()) { foreach (var interfaceType in entityType.GetInterfaces()) { if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEntity <>)) { var primaryKeyType = interfaceType.GenericTypeArguments[0]; if (primaryKeyType == typeof(int)) { var genericRepositoryType = autoRepositoryAttr.RepositoryInterface.MakeGenericType(entityType); if (!iocManager.IsRegistered(genericRepositoryType)) { var implType = autoRepositoryAttr.RepositoryImplementation.GetGenericArguments().Length == 1 ? autoRepositoryAttr.RepositoryImplementation.MakeGenericType(entityType) : autoRepositoryAttr.RepositoryImplementation.MakeGenericType(dbContextType, entityType); iocManager.Register( genericRepositoryType, implType, DependencyLifeStyle.Transient ); } } var genericRepositoryTypeWithPrimaryKey = autoRepositoryAttr.RepositoryInterfaceWithPrimaryKey.MakeGenericType(entityType, primaryKeyType); if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) { var implType = autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.GetGenericArguments().Length == 2 ? autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(entityType, primaryKeyType) : autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(dbContextType, entityType, primaryKeyType); iocManager.Register( genericRepositoryTypeWithPrimaryKey, implType, DependencyLifeStyle.Transient ); } } } } }
public virtual void RegisterRepositories(IIocManager iocManager, AutoRepositoryTypesAttribute defaultRepositoryTypes) { var autoRepositoryAttr = dbContextType.GetTypeInfo() .GetSingleAttributeOrNull <AutoRepositoryTypesAttribute>() ?? defaultRepositoryTypes; foreach (var entityTypeInfo in dbContextEntityFinder.GetEntityTypeInfos(dbContextType)) { var primaryKeyType = EntityHelper.GetPrimaryKeyType(entityTypeInfo.EntityType); if (primaryKeyType == typeof(int)) { var genericRepositoryType = autoRepositoryAttr.RepositoryInterface.MakeGenericType(entityTypeInfo.EntityType); if (!iocManager.IsRegistered(genericRepositoryType)) { var implType = autoRepositoryAttr.RepositoryImplementation.GetTypeInfo().GetGenericArguments() .Length == 1 ? autoRepositoryAttr.RepositoryImplementation.MakeGenericType(entityTypeInfo.EntityType) : autoRepositoryAttr.RepositoryImplementation.MakeGenericType(entityTypeInfo.DeclaringType, entityTypeInfo.EntityType); iocManager.Register( genericRepositoryType, implType, DependencyLifeStyle.Transient ); } } var genericRepositoryTypeWithPrimaryKey = autoRepositoryAttr.RepositoryInterfaceWithPrimaryKey.MakeGenericType(entityTypeInfo.EntityType, primaryKeyType); if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) { var implType = autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.GetTypeInfo() .GetGenericArguments().Length == 2 ? autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType( entityTypeInfo.EntityType, primaryKeyType) : autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType( entityTypeInfo.DeclaringType, entityTypeInfo.EntityType, primaryKeyType); iocManager.Register( genericRepositoryTypeWithPrimaryKey, implType, DependencyLifeStyle.Transient ); } } }
public void RegisterRepositories(IIocManager iocManager, AutoRepositoryTypesAttribute defaultRepositoryTypes) { if (defaultRepositoryTypes.WithDefaultRepositoryInterfaces) { iocManager.IocContainer.Register( Component.For(typeof(IRepository <>), defaultRepositoryTypes.RepositoryInterface).ImplementedBy(defaultRepositoryTypes.RepositoryImplementation).LifestyleTransient(), Component.For(typeof(IRepository <,>), defaultRepositoryTypes.RepositoryInterfaceWithPrimaryKey).ImplementedBy(defaultRepositoryTypes.RepositoryImplementationWithPrimaryKey).LifestyleTransient() ); } else { iocManager.Register(defaultRepositoryTypes.RepositoryInterface, defaultRepositoryTypes.RepositoryImplementation, DependencyLifeStyle.Transient); iocManager.Register(defaultRepositoryTypes.RepositoryInterfaceWithPrimaryKey, defaultRepositoryTypes.RepositoryImplementationWithPrimaryKey, DependencyLifeStyle.Transient); } }
/// <summary> /// 加载所有组件。 /// </summary> private void LoadAllComponents() { ICollection <Type> componentTypes = AddMissingDependedComponents(_componentFinder.FindAll()); foreach (Type componentType in componentTypes) { if (!ComponentBase.IsComponent(componentType)) { throw new Exception(string.Format("{0} 不是 Ls 组件。", componentType.AssemblyQualifiedName)); } if (!_iocManager.IsRegistered(componentType)) { _iocManager.Register(componentType); } } foreach (Type componentType in componentTypes) { ComponentBase componentObject = (ComponentBase)_iocManager.Resolve(componentType); componentObject.IocManager = _iocManager; _components.Add(new ComponentDescription(componentObject)); } int coreComponentIndex = _components.FindIndex(m => m.Type == typeof(LsCoreComponent)); if (coreComponentIndex > 0) { ComponentDescription coreComponent = _components[coreComponentIndex]; _components.RemoveAt(coreComponentIndex); _components.Insert(0, coreComponent); } SetDependencies(); }
public void EnableDbLocalization() { _iocManager.Register <ILanguageProvider, ApplicationLanguageProvider>(DependencyLifeStyle.Transient); var sources = _configuration .Localization .Sources .Where(s => s is IDictionaryBasedLocalizationSource) .Cast <IDictionaryBasedLocalizationSource>() .ToList(); foreach (var source in sources) { _configuration.Localization.Sources.Remove(source); _configuration.Localization.Sources.Add( new MultiTenantLocalizationSource( source.Name, new MultiTenantLocalizationDictionaryProvider( source.DictionaryProvider, _iocManager ) ) ); Logger.DebugFormat("Converted {0} ({1}) to MultiTenantLocalizationSource", source.Name, source.GetType()); } }
public static void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { var autoRepositoryAttr = dbContextType.GetSingleAttributeOrNull<AutoRepositoryTypesAttribute>(); if (autoRepositoryAttr == null) { autoRepositoryAttr = AutoRepositoryTypesAttribute.Default; } foreach (var entityType in dbContextType.GetEntityTypes()) { var genericRepositoryType = autoRepositoryAttr.RepositoryInterface.MakeGenericType(entityType); if (!iocManager.IsRegistered(genericRepositoryType)) { var implType = autoRepositoryAttr.RepositoryImplementation.GetGenericArguments().Length == 1 ? autoRepositoryAttr.RepositoryImplementation.MakeGenericType(entityType) : autoRepositoryAttr.RepositoryImplementation.MakeGenericType(dbContextType, entityType); iocManager.Register( genericRepositoryType, implType, DependencyLifeStyle.Multiple ); } } }
public static void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { var repositoryType = dbContextType.Assembly.GetTypes().Where(type => !string.IsNullOrEmpty(type.Namespace)) .Where(type => type.BaseType != null && type.BaseType.IsGenericType && (type.BaseType.GetGenericTypeDefinition() == typeof(IRepository<>) || type.BaseType.GetGenericTypeDefinition() == typeof(IRepository<,>) || type.BaseType.GetGenericTypeDefinition() == typeof(EfRepositoryBase<,>) || type.BaseType.GetGenericTypeDefinition() == typeof(EfRepositoryBase<,,>))); foreach (var entityType in dbContextType.GetEntityTypes())//从dataset中获取所有的实体 { foreach (var interfaceType in entityType.GetInterfaces())//获取所有实体实现的接口 { if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEntity<>)) { var primaryKeyType = interfaceType.GenericTypeArguments[0];//获取所有的实体的主键 foreach (var maprepositoryType in repositoryType) { if (!iocManager.IsRegistered(maprepositoryType)) { var implType = maprepositoryType.GetGenericArguments().Length == 2 ? maprepositoryType.MakeGenericType(entityType, primaryKeyType) : maprepositoryType.MakeGenericType(dbContextType, entityType, primaryKeyType); iocManager.Register( maprepositoryType, implType, DependencyLifeStyle.Transient ); } } } } } }
/// <summary> /// Initialize assmeblies registration in order to register into the ioc container. /// </summary> internal static void Initialize() { var registeredAssmeblies = new HashSet <string>(); var imcAsm = typeof(ILoggerPoolFactory).Assembly; iocManager.RegisterAssemblyAsInterfaces(imcAsm); registeredAssmeblies.Add(imcAsm.FullName); var assemblyFinder = iocManager.Resolve <IAssemblyFinder>(); foreach (var asm in assemblyFinder.GetAllAssemblies().Union(assemblyFinder.GetAllBinDirectoryAssemblies())) { try { if (registeredAssmeblies.Contains(asm.FullName)) { continue; } var types = asm.GetExportedTypes(); foreach (var type in types) { if (type.Namespace.StartsWith(ImcFrameworkConstants.ImcFramework)) { iocManager.RegisterAssemblyAsInterfaces(asm); registeredAssmeblies.Add(asm.FullName); break; } } } catch { } } //register the progressInfoManager as singleton iocManager.Register <IProgressInfoManager>(ProgressInfoManager.Instance); //load the Global Register & call the register method var gl = iocManager.Resolve <IEnumerable <IGlobalRegister> >(); gl.ToList().ForEach(zw => { zw.Register(iocManager); }); //resolve the modules buildInModules = iocManager.Resolve <IEnumerable <IServiceModule> >(); extensionModules = iocManager.Resolve <IEnumerable <IModuleExtension> >(); }
public void TestMethod2() { _iocManager.Register <ITaskService, TaskService>(DependencyLifeStyle.Transient); ITaskService taskService = _iocManager.Resolve <ITaskService>(); Assert.AreEqual("aa", taskService.SaveTask("aa")); }
public static void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { var autoRepositoryAttr = dbContextType.GetSingleAttributeOrNull<AutoRepositoryTypesAttribute>() ?? AutoRepositoryTypesAttribute.Default; foreach (var entityType in dbContextType.GetEntityTypes()) { foreach (var interfaceType in entityType.GetInterfaces()) { if (!interfaceType.IsGenericType || interfaceType.GetGenericTypeDefinition() != typeof (IEntity<>)) continue; var primaryKeyType = interfaceType.GenericTypeArguments[0]; if (primaryKeyType == typeof(int)) { var genericRepositoryType = autoRepositoryAttr.RepositoryInterface.MakeGenericType(entityType); if (!iocManager.IsRegistered(genericRepositoryType)) { var implType = autoRepositoryAttr.RepositoryImplementation.GetGenericArguments().Length == 1 ? autoRepositoryAttr.RepositoryImplementation.MakeGenericType(entityType) : autoRepositoryAttr.RepositoryImplementation.MakeGenericType(dbContextType, entityType); iocManager.Register( genericRepositoryType, implType, DependencyLifeStyle.Transient ); } } var genericRepositoryTypeWithPrimaryKey = autoRepositoryAttr.RepositoryInterfaceWithPrimaryKey.MakeGenericType(entityType, primaryKeyType); if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) { var implType = autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.GetGenericArguments().Length == 2 ? autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(entityType, primaryKeyType) : autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(dbContextType, entityType, primaryKeyType); iocManager.Register( genericRepositoryTypeWithPrimaryKey, implType, DependencyLifeStyle.Transient ); } } } }
public static void RegisterGenericRepositories <TTenantId, TUserId>(Type[] entities, IIocManager iocManager) where TTenantId : struct where TUserId : struct { foreach (var entityType in entities) { var interfaces = entityType.GetInterfaces(); foreach (var interfaceType in interfaces) { if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEntity <>)) { var primaryKeyType = interfaceType.GenericTypeArguments[0]; if (primaryKeyType.Name == "TPrimaryKey" || string.IsNullOrEmpty(primaryKeyType.FullName)) { continue; } if (primaryKeyType == typeof(int)) { var genericRepositoryType = typeof(IRepository <>).MakeGenericType(entityType); if (!iocManager.IsRegistered(genericRepositoryType)) { iocManager.Register( genericRepositoryType, typeof(NhRepositoryBase <, ,>).MakeGenericType(entityType, typeof(TTenantId), typeof(TUserId)), DependencyLifeStyle.Transient ); } } var genericRepositoryTypeWithPrimaryKey = typeof(IRepository <,>).MakeGenericType(entityType, primaryKeyType); if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) { iocManager.Register( genericRepositoryTypeWithPrimaryKey, typeof(NhRepositoryBase <, , ,>).MakeGenericType(entityType, primaryKeyType, typeof(TTenantId), typeof(TUserId)), DependencyLifeStyle.Transient ); } } } } }
private SettingProvider CreateProvider(Type providerType) { if (!_iocManager.IsRegistered(providerType)) { _iocManager.Register(providerType); } return((SettingProvider)_iocManager.Resolve(providerType)); }
private AuthorizationProvider CreateAuthorizationProvider(Type providerType) { if (!_iocManager.IsRegistered(providerType)) { _iocManager.Register(providerType); } return((AuthorizationProvider)_iocManager.Resolve(providerType)); }
/// <summary> /// 将<paramref name="dbContextType"/>类型对应的实体仓储注册到<paramref name="iocManager"/>对象中。 /// </summary> /// <param name="dbContextType">数据库上下文类型</param> /// <param name="iocManager">IoC 管理器</param> public static void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { // 遍历 DbContext 的所有实体 foreach (var entityType in dbContextType.GetEntityTypes()) { // 遍历实体继承的所有接口 foreach (var interfaceType in entityType.GetInterfaces()) { // 判断泛型接口且接口类型为IEntity<> if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEntity <>)) { // 获取实体主键类型 var primaryKeyType = interfaceType.GenericTypeArguments[0]; if (primaryKeyType == typeof(Int64)) { var genericRepositoryType = typeof(IRepository <>).MakeGenericType(entityType); if (!iocManager.IsRegistered(genericRepositoryType)) { iocManager.Register( genericRepositoryType, typeof(EfRepository <,>).MakeGenericType(dbContextType, entityType), DependencyLifeCycle.Transient ); } } var genericRepositoryTypeWithPrimaryKey = typeof(IRepository <,>).MakeGenericType(entityType, primaryKeyType); if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) { iocManager.Register( genericRepositoryTypeWithPrimaryKey, typeof(EfRepository <, ,>).MakeGenericType(dbContextType, entityType, primaryKeyType), DependencyLifeCycle.Transient ); } else { var obj = iocManager.Resolve(genericRepositoryTypeWithPrimaryKey); } } } } }
/// <summary> /// 注册数据上下文 /// </summary> /// <param name="dbContextType">数据上下文类型</param> /// <param name="iocManager">IOC管理</param> public static void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { //获取AutoRepositoryTypesAttribute自动仓储类型自定义属性的类型 var autoRepositoryAttr = dbContextType.GetSingleAttributeOrNull<AutoRepositoryTypesAttribute>(); if (autoRepositoryAttr == null) { autoRepositoryAttr = AutoRepositoryTypesAttribute.Default; } foreach (var entityType in dbContextType.GetEntityTypes()) { var primaryKeyType = EntityHelper.GetPrimaryKeyType(entityType); if (primaryKeyType == typeof(int)) { var genericRepositoryType = autoRepositoryAttr.RepositoryInterface.MakeGenericType(entityType); if (!iocManager.IsRegistered(genericRepositoryType)) { var implType = autoRepositoryAttr.RepositoryImplementation.GetGenericArguments().Length == 1 ? autoRepositoryAttr.RepositoryImplementation.MakeGenericType(entityType) : autoRepositoryAttr.RepositoryImplementation.MakeGenericType(dbContextType, entityType); iocManager.Register( genericRepositoryType, implType, DependencyLifeStyle.Transient ); } } var genericRepositoryTypeWithPrimaryKey = autoRepositoryAttr.RepositoryInterfaceWithPrimaryKey.MakeGenericType(entityType, primaryKeyType); if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) { var implType = autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.GetGenericArguments().Length == 2 ? autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(entityType, primaryKeyType) : autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(dbContextType, entityType, primaryKeyType); iocManager.Register( genericRepositoryTypeWithPrimaryKey, implType, DependencyLifeStyle.Transient ); } } }
/// <summary> /// 国际支付宝支付配置 /// </summary> /// <param name="logAction"></param> /// <param name="iocManager"></param> /// <param name="config"></param> /// <param name="settingManager"></param> /// <returns></returns> private static async Task <IGlobalAlipaySettings> GlobalAlipayConfig(Action <string, string> logAction, IIocManager iocManager, IConfigurationRoot config, ISettingManager settingManager) { #region 支付宝支付 IGlobalAlipaySettings alipaySettings = null; if (Convert.ToBoolean(await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.IsActive))) { alipaySettings = new GlobalAlipaySettings { Key = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.Key), Partner = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.Partner), Gatewayurl = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.Gatewayurl), Notify = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.Notify), ReturnUrl = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.ReturnUrl), Currency = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.Currency), }; var splitFundSettingsString = await settingManager.GetSettingValueAsync(AppSettings.GlobalAliPayManagement.SplitFundSettings); if (!splitFundSettingsString.IsNullOrWhiteSpace()) { alipaySettings.SplitFundInfo = JsonConvert.DeserializeObject <List <SplitFundSettingInfoDto> >(splitFundSettingsString); } } else if (!config["GlobalAlipay:IsEnabled"].IsNullOrWhiteSpace() && Convert.ToBoolean(config["Alipay:IsEnabled"])) { alipaySettings = new GlobalAlipaySettings { Key = config["GlobalAlipay:Key"], Partner = config["GlobalAlipay:Partner"], Gatewayurl = config["GlobalAlipay:Gatewayurl"], Notify = config["GlobalAlipay:Notify"], ReturnUrl = config["GlobalAlipay:ReturnUrl"], Currency = config["GlobalAlipay:Currency"], }; var splitFundSettingsString = config["GlobalAlipay:SplitFundInfo"]; if (!splitFundSettingsString.IsNullOrWhiteSpace()) { alipaySettings.SplitFundInfo = JsonConvert.DeserializeObject <List <SplitFundSettingInfoDto> >(splitFundSettingsString); } } if (alipaySettings != null) { GlobalAlipayBuilder.Create() .WithLoggerAction(logAction) .RegisterGetPayConfigFunc(() => alipaySettings).Build(); //注册支付宝支付API if (!iocManager.IsRegistered <IGlobalAlipayAppService>()) { iocManager.Register <IGlobalAlipayAppService, GlobalAlipayAppService>(DependencyLifeStyle.Transient); } } #endregion return(alipaySettings); }
public static void RegisterForService(IIocManager iocManager) { var typetoMap = Assembly.GetExecutingAssembly().GetTypes() .Where(type => !string.IsNullOrEmpty(type.Namespace)) .Where(type => type.BaseType != null && type.BaseType.IsInterface && type.BaseType == typeof(IApplicationService)); foreach (var mapType in typetoMap) { iocManager.Register(mapType, DependencyLifeStyle.Transient); } }
public void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { var autoRepositoryAttr = dbContextType.GetSingleAttributeOrNull<AutoRepositoryTypesAttribute>() ?? EfCoreAutoRepositoryTypes.Default; foreach (var entityTypeInfo in DbContextHelper.GetEntityTypeInfos(dbContextType)) { var primaryKeyType = EntityHelper.GetPrimaryKeyType(entityTypeInfo.EntityType); if (primaryKeyType == typeof(int)) { var genericRepositoryType = autoRepositoryAttr.RepositoryInterface.MakeGenericType(entityTypeInfo.EntityType); if (!iocManager.IsRegistered(genericRepositoryType)) { var implType = autoRepositoryAttr.RepositoryImplementation.GetGenericArguments().Length == 1 ? autoRepositoryAttr.RepositoryImplementation.MakeGenericType(entityTypeInfo.EntityType) : autoRepositoryAttr.RepositoryImplementation.MakeGenericType(entityTypeInfo.DeclaringType, entityTypeInfo.EntityType); iocManager.Register( genericRepositoryType, implType, DependencyLifeStyle.Transient ); } } var genericRepositoryTypeWithPrimaryKey = autoRepositoryAttr.RepositoryInterfaceWithPrimaryKey.MakeGenericType(entityTypeInfo.EntityType, primaryKeyType); if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) { var implType = autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.GetGenericArguments().Length == 2 ? autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(entityTypeInfo.EntityType, primaryKeyType) : autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(entityTypeInfo.DeclaringType, entityTypeInfo.EntityType, primaryKeyType); iocManager.Register( genericRepositoryTypeWithPrimaryKey, implType, DependencyLifeStyle.Transient ); } } }
public void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { AutoRepositoryTypesAttribute autoRepositoryAttr = dbContextType.GetSingleAttributeOrNull <DapperAutoRepositoryTypeAttribute>() ?? DapperAutoRepositoryTypes.Default; foreach (EntityTypeInfo entityTypeInfo in DbContextHelper.GetEntityTypeInfos(dbContextType)) { Type primaryKeyType = EntityHelper.GetPrimaryKeyType(entityTypeInfo.EntityType); if (primaryKeyType == typeof(int)) { Type genericRepositoryType = autoRepositoryAttr.RepositoryInterface.MakeGenericType(entityTypeInfo.EntityType); if (!iocManager.IsRegistered(genericRepositoryType)) { Type implType = autoRepositoryAttr.RepositoryImplementation.GetGenericArguments().Length == 1 ? autoRepositoryAttr.RepositoryImplementation.MakeGenericType(entityTypeInfo.EntityType) : autoRepositoryAttr.RepositoryImplementation.MakeGenericType(entityTypeInfo.DeclaringType, entityTypeInfo.EntityType); iocManager.Register( genericRepositoryType, implType, DependencyLifeStyle.Transient ); } } Type genericRepositoryTypeWithPrimaryKey = autoRepositoryAttr.RepositoryInterfaceWithPrimaryKey.MakeGenericType(entityTypeInfo.EntityType, primaryKeyType); if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) { Type implType = autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.GetGenericArguments().Length == 2 ? autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(entityTypeInfo.EntityType, primaryKeyType) : autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(entityTypeInfo.DeclaringType, entityTypeInfo.EntityType, primaryKeyType); iocManager.Register( genericRepositoryTypeWithPrimaryKey, implType, DependencyLifeStyle.Transient ); } } }
private void LoadAll() { Logger.Debug("Loading Abp modules..."); var moduleTypes = AddMissingDependedModules(_moduleFinder.FindAll()); Logger.Debug("Found " + moduleTypes.Count + " ABP modules in total."); //Register to IOC container. foreach (var moduleType in moduleTypes) { if (!AbpModule.IsAbpModule(moduleType)) { throw new AbpInitializationException("This type is not an ABP module: " + moduleType.AssemblyQualifiedName); } if (!_iocManager.IsRegistered(moduleType)) { _iocManager.Register(moduleType); } } //Add to module collection foreach (var moduleType in moduleTypes) { var moduleObject = (AbpModule)_iocManager.Resolve(moduleType); moduleObject.IocManager = _iocManager; moduleObject.Configuration = _iocManager.Resolve <IAbpStartupConfiguration>(); _modules.Add(new AbpModuleInfo(moduleObject)); Logger.DebugFormat("Loaded module: " + moduleType.AssemblyQualifiedName); } //AbpKernelModule must be the first module //var startupModuleIndex = _modules.FindIndex(m => m.Type == typeof(AbpKernelModule<TTenantId, TUserId>)); //var startupModuleIndex = _modules.FindIndex(m => m.Type == typeof(AbpKernelModule<,>)); var startupModuleIndex = _modules.FindIndex(m => m.Type == typeof(AbpKernelModule)); if (startupModuleIndex > 0) { var startupModule = _modules[startupModuleIndex]; _modules.RemoveAt(startupModuleIndex); _modules.Insert(0, startupModule); } SetDependencies(); Logger.DebugFormat("{0} modules loaded.", _modules.Count); }
/// <summary> /// 支付回调配置 /// </summary> /// <param name="logAction"></param> public void PayNotifyConfig(Action <string, string> logAction) { if (_iocManager.IsRegistered <PayNotifyController>()) { return; } //注册支付回调控制器 _iocManager.Register <PayNotifyController>(DependencyLifeStyle.Transient); //支付回调设置 PayNotifyBuilder .Create() //设置日志记录 .WithLoggerAction(logAction).WithPayNotifyFunc(async input => await ExecPayNotifyAsync(input)).Build(); }
public void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { foreach (var entityTypeInfo in _dbContextEntityFinder.GetEntityTypeInfos(dbContextType)) { var repositoryInterface = typeof(IEntityCoreCache <>); var repositoryImplementation = typeof(EntityCoreCache <>); var primaryKeyType = EntityHelper.GetPrimaryKeyType(entityTypeInfo.EntityType); if (primaryKeyType == typeof(int)) { var genericRepositoryType = repositoryInterface.MakeGenericType(entityTypeInfo.EntityType); if (!iocManager.IsRegistered(genericRepositoryType)) { var implType = repositoryImplementation.GetGenericArguments().Length == 1 ? repositoryImplementation.MakeGenericType(entityTypeInfo.EntityType) : repositoryImplementation.MakeGenericType(entityTypeInfo.DeclaringType, entityTypeInfo.EntityType); iocManager.IocContainer.Register( Component .For(genericRepositoryType) .ImplementedBy(implType) .Named(Guid.NewGuid().ToString("N")) .LifestyleTransient() ); iocManager.Register(implType, DependencyLifeStyle.Transient); } } //var genericRepositoryTypeWithPrimaryKey = repositoryInterfaceWithPrimaryKey.MakeGenericType(entityTypeInfo.EntityType, primaryKeyType); //if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey)) //{ // var implType = repositoryImplementationWithPrimaryKey.GetGenericArguments().Length == 2 // ? repositoryImplementationWithPrimaryKey.MakeGenericType(entityTypeInfo.EntityType, primaryKeyType) // : repositoryImplementationWithPrimaryKey.MakeGenericType(entityTypeInfo.DeclaringType, entityTypeInfo.EntityType, primaryKeyType); // iocManager.IocContainer.Register( // Component // .For(genericRepositoryTypeWithPrimaryKey) // .ImplementedBy(implType) // .Named(Guid.NewGuid().ToString("N")) // .LifestyleTransient() // ); //} } }
/// <summary> /// 微信支付配置 /// </summary> /// <param name="logAction"></param> /// <param name="iocManager"></param> /// <param name="config"></param> /// <param name="settingManager"></param> /// <returns></returns> private static async Task <DefaultWeChatPayConfig> WeChatPayConfig(Action <string, string> logAction, IIocManager iocManager, IConfigurationRoot config, ISettingManager settingManager) { #region 微信支付 DefaultWeChatPayConfig weChatPayConfig = null; if (Convert.ToBoolean(await settingManager.GetSettingValueAsync(AppSettings.WeChatPayManagement.IsActive))) { weChatPayConfig = new DefaultWeChatPayConfig() { PayAppId = await settingManager.GetSettingValueAsync(AppSettings.WeChatPayManagement.AppId), MchId = await settingManager.GetSettingValueAsync(AppSettings.WeChatPayManagement.MchId), PayNotifyUrl = await settingManager.GetSettingValueAsync(AppSettings.WeChatPayManagement.PayNotifyUrl), TenPayKey = await settingManager.GetSettingValueAsync(AppSettings.WeChatPayManagement.TenPayKey), }; } else if (!config["WeChat:Pay:IsEnabled"].IsNullOrWhiteSpace() && Convert.ToBoolean(config["WeChat:Pay:IsEnabled"])) { weChatPayConfig = new DefaultWeChatPayConfig { MchId = config["WeChat:Pay:MchId"], PayNotifyUrl = config["WeChat:Pay:NotifyUrl"], TenPayKey = config["WeChat:Pay:TenPayKey"], PayAppId = config["WeChat:Pay:AppId"] }; } if (weChatPayConfig != null) { //微信支付配置 WeChatPayBuilder.Create() //设置日志记录 .WithLoggerAction(logAction) .RegisterGetPayConfigFunc(() => weChatPayConfig).Build(); //注册微信支付API if (!iocManager.IsRegistered <WeChatPayApi>()) { iocManager.Register <WeChatPayApi>(DependencyLifeStyle.Transient); } } #endregion return(weChatPayConfig); }
private void LoadAll() { Logger.Debug("Loading Ns modules..."); var moduleTypes = AddMissingDependedModules(_moduleFinder.FindAll()); Logger.Debug("Found " + moduleTypes.Count + " NS modules in total."); //Register to IOC container. foreach (var moduleType in moduleTypes) { if (!NsModule.IsNsModule(moduleType)) { throw new NsInitializationException("This type is not an NS module: " + moduleType.AssemblyQualifiedName); } if (!_iocManager.IsRegistered(moduleType)) { _iocManager.Register(moduleType); } } //Add to module collection foreach (var moduleType in moduleTypes) { var moduleObject = (NsModule)_iocManager.Resolve(moduleType); moduleObject.IocManager = _iocManager; //moduleObject.Configuration = _iocManager.Resolve<IAbpStartupConfiguration>(); _modules.Add(new NsModuleInfo(moduleObject)); Logger.DebugFormat("Loaded module: " + moduleType.AssemblyQualifiedName); } EnsureKernelModuleToBeFirst(); SetDependencies(); Logger.DebugFormat("{0} modules loaded.", _modules.Count); }
private void LoadAll() { Logger.Debug("加载 EddoModule..."); var moduleTypes = AddMissingDependedModules(_moduleFinder.FindAll()); Logger.Debug("发现 " + moduleTypes.Count + " EddoModule"); //注册ioc容器 foreach (var moduleType in moduleTypes) { if (!EddoModule.IsEddoModule(moduleType)) { throw new Exception("此类型不是EddoModule类型: " + moduleType.AssemblyQualifiedName); } if (!_iocManager.IsRegistered(moduleType)) { _iocManager.Register(moduleType); } } //添加模块 foreach (var moduleType in moduleTypes) { var moduleObject = (EddoModule)_iocManager.Resolve(moduleType); moduleObject.IocManager = _iocManager; moduleObject.Configuration = _iocManager.Resolve <IEddoStartupConfiguration>(); _modules.Add(new EddoModuleInfo(moduleObject)); Logger.DebugFormat("加载模块: " + moduleType.AssemblyQualifiedName); } EnsureKernelModuleToBeFirst(); SetDependencies(); Logger.DebugFormat("{0} modules loaded.", _modules.Count); }
private void LoadAll() { Logger.Debug("开始加载模块"); var moduleTypes = AddMissingDependedModules(_moduleFinder.FindAll()); Logger.Debug("查找到 " + moduleTypes.Count + " 个模块"); //Register to IOC container. foreach (var moduleType in moduleTypes) { if (!Module.IsModule(moduleType)) { throw new Exception("此类型不是有效的模块: " + moduleType.AssemblyQualifiedName); } if (!_iocManager.IsRegistered(moduleType)) { _iocManager.Register(moduleType); } } //Add to module collection foreach (var moduleType in moduleTypes) { var moduleObject = (Module)_iocManager.Resolve(moduleType); moduleObject.IocManager = _iocManager; moduleObject.Configuration = _iocManager.Resolve <IStartupConfiguration>(); _modules.Add(new ModuleInfo(moduleObject)); Logger.Debug("已加载模块: " + moduleType.AssemblyQualifiedName); } EnsureKernelModuleToBeFirst(); SetDependencies(); Logger.Debug(string.Format("{0} modules loaded.", _modules.Count)); }
public TestBaseWithLocalIocManager() { LocalIocManager = new IocManager(); /* * 需要注意注册的次序! * 先注册拦截器 */ //开启uow事务 UnitOfWorkRegistrar.Initialize(LocalIocManager); LocalIocManager.IocContainer.Register( Component.For(typeof(IDbContextProvider <>)).ImplementedBy(typeof(UnitOfWorkDbContextProvider <>)).LifestyleTransient(), Component.For <IUnitOfWorkDefaultOptions, UnitOfWorkDefaultOptions>().ImplementedBy <UnitOfWorkDefaultOptions>().LifestyleSingleton(), Component.For <IIocResolver, IocManager>().ImplementedBy <IocManager>().LifestyleSingleton(), Component.For <IUnitOfWorkManager>().ImplementedBy <UnitOfWorkManager>().LifestyleSingleton() ); LocalIocManager.Register(typeof(UnitOfWorkInterceptor), DependencyLifeStyle.Singleton); //IocManager.Register<HelpController>(DependencyLifeStyle.Transient); LocalIocManager.IocContainer.Install(new FinderInstaller()); LocalIocManager.AddConventionalRegistrar(new BasicConventionalRegistrar()); LocalIocManager.RegisterAssemblyByConvention(typeof(IRepository).Assembly); LocalIocManager.RegisterAssemblyByConvention(typeof(DomainServiceBase).Assembly); LocalIocManager.RegisterAssemblyByConvention(typeof(AppServiceBase).Assembly); //LocalIocManager.RegisterAssemblyByConvention(typeof(TestBaseWithLocalIocManager).Assembly); //LocalIocManager.RegisterAssemblyByConvention(Assembly.Load("DDD.Domain.Common")); LocalIocManager.RegisterAssemblyByConvention(Assembly.Load("DDD.Domain.Core")); LocalIocManager.RegisterAssemblyByConvention(Assembly.Load("DDD.Domain.Service")); //IocManager.Register<IBlogRepository>(); //IocManager.Register<IUserRepository>(); }
public void RegisterForDbContext(Type dbContextType, IIocManager iocManager) { var RepositoryInterface = typeof(IExtendedRepository <>); var RepositoryImplementation = typeof(EfRepositoryBase <,>); foreach (EntityTypeInfo entityTypeInfo in ExtendedDbContextHelper.GetDbEntityTypeInfos(dbContextType)) { Type genericRepositoryType = RepositoryInterface.MakeGenericType(new Type[] { entityTypeInfo.EntityType }); if (!iocManager.IsRegistered(genericRepositoryType)) { Type implType = (RepositoryImplementation.GetGenericArguments().Length == 1) ? RepositoryImplementation.MakeGenericType(new Type[] { entityTypeInfo.EntityType }) : RepositoryImplementation.MakeGenericType(new Type[] { entityTypeInfo.DeclaringType, entityTypeInfo.EntityType }); iocManager.Register(genericRepositoryType, implType, DependencyLifeStyle.Transient); } } }
public OracleTestBaseWithLocalIocManager() { LocalIocManager = new IocManager(); /* * 需要注意注册的次序! * 先注册拦截器 */ //开启uow事务 UnitOfWorkRegistrar.Initialize(LocalIocManager); LocalIocManager.IocContainer.Register( Component.For(typeof(IDbContextProvider <>)).ImplementedBy(typeof(UnitOfWorkDbContextProvider <>)).LifestyleTransient(), Component.For <IUnitOfWorkDefaultOptions, UnitOfWorkDefaultOptions>().ImplementedBy <UnitOfWorkDefaultOptions>().LifestyleSingleton(), Component.For <IIocResolver, IocManager>().ImplementedBy <IocManager>().LifestyleSingleton(), Component.For <IUnitOfWorkManager>().ImplementedBy <UnitOfWorkManager>().LifestyleSingleton() //Component.For<IAutoMapperInitializer, AutoMapperInitializer>().ImplementedBy<AutoMapperInitializer>().LifestyleSingleton() ); LocalIocManager.Register(typeof(UnitOfWorkInterceptor), DependencyLifeStyle.Singleton); //IocManager.Register<HelpController>(DependencyLifeStyle.Transient); LocalIocManager.IocContainer.Install(new FinderInstaller()); LocalIocManager.AddConventionalRegistrar(new BasicConventionalRegistrar()); LocalIocManager.RegisterAssemblyByConvention(typeof(IAutoMapperModule).Assembly); LocalIocManager.RegisterAssemblyByConvention(typeof(IInfrastructureDomainModule).Assembly); LocalIocManager.RegisterAssemblyByConvention(typeof(IDomainCoreModule).Assembly); LocalIocManager.RegisterAssemblyByConvention(typeof(IDomainServiceModule).Assembly); LocalIocManager.RegisterAssemblyByConvention(typeof(IAppServiceModule).Assembly); }
private static Type GetMakedGenericType <TTenantId, TUserId>(bool hasPrimaryKey, IIocManager iocManager, AutoRepositoryTypeAttribute autoRepositoryAttr, Type dbContextType, Type entityType, Type primaryKeyType) { var genericArgs = hasPrimaryKey ? autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.GetGenericArguments() : autoRepositoryAttr.RepositoryImplementation.GetGenericArguments(); var types = new List <Type>(); foreach (var ga in genericArgs) { switch (ga.Name) { case "TDbContext": types.Add(dbContextType); break; case "TEntity": types.Add(entityType); break; case "TPrimaryKey": types.Add(primaryKeyType); break; case "TTenantId": types.Add(typeof(TTenantId)); break; case "TUserId": types.Add(typeof(TUserId)); break; } } var implType = hasPrimaryKey ? autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(types.ToArray()) : autoRepositoryAttr.RepositoryImplementation.MakeGenericType(types.ToArray()); if (string.IsNullOrEmpty(implType.FullName)) { var makedDbContextType = dbContextType.MakeGenericType(typeof(TTenantId), typeof(TUserId)); if (!iocManager.IsRegistered(makedDbContextType)) { iocManager.Register(makedDbContextType, DependencyLifeStyle.Transient); } if (types[0] == dbContextType) { types[0] = makedDbContextType; } else { throw new InvalidOperationException("Type of TDbContext can not be substituted."); } implType = hasPrimaryKey ? autoRepositoryAttr.RepositoryImplementationWithPrimaryKey.MakeGenericType(types.ToArray()) : autoRepositoryAttr.RepositoryImplementation.MakeGenericType(types.ToArray()); } return(implType); }
private void RegisterModel(IIocManager iocManager) { iocManager.Register<IComTest,ComTest>(); }
private void Application_Start() { TestAssemblyFinder finder = new TestAssemblyFinder(); _iocManager = IocManager.Instance; _iocManager.Register(typeof(IAssemblyFinder), typeof(TestAssemblyFinder), DependencyLifeStyle.Singleton); CoreBootstrapper core = new CoreBootstrapper(_iocManager); core.Initialize(); }