/// <summary> /// 初始化实体模型生成器 /// </summary> /// <param name="configurations">实体模型生成器</param> public static void ConfigurationsInit(ConfigurationRegistrar configurations) { foreach (var configuration in Configurations) { configuration.RegistTo(configurations); } }
private static ConfigurationRegistrar UseAccountDbMigration(this ConfigurationRegistrar config) { config.Add(new AppUserConfigurations()); config.Add(new AppRoleConfigurations()); return(config); }
public static void Register(ConfigurationRegistrar configurations) { configurations.Add(new SubscriptionConfiguration()); configurations.Add(new UserConfiguration()); configurations.Add(new RoleConfiguration()); configurations.Add(new ContentAttachmentConfiguration()); configurations.Add(new CategoryConfiguration()); configurations.Add(new TagConfiguration()); configurations.Add(new VoteConfiguration()); configurations.Add(new FollowConfiguration()); configurations.Add(new LikeConfiguration()); configurations.Add(new MovedUrlConfiguration()); configurations.Add(new SqlAbuseConfiguration()); //configurations.Add(new SqlEmailQueueItemConfiguration()); configurations.Add(new SqlUserProfileConfiguration()); configurations.Add(new SqlWebConfiguration()); configurations.Add(new SqlWebPageConfiguration()); configurations.Add(new SqlWebPageVersionConfiguration()); configurations.Add(new SqlWidgetConfiguration()); configurations.Add(new SqlWidgetDescriptorConfiguration()); configurations.Add(new SqlPermissionsetsConfiguration()); configurations.Add(new SqlPermissionsConfiguration()); configurations.Add(new SqlContentListConfiguration()); configurations.Add(new SqlContentViewConfiguration()); configurations.Add(new SqlContentFormConfiguration()); configurations.Add(new SqlContentItemDataConfiguration()); configurations.Add(new SqlCommentConfiguration()); }
public void RegisterConfiguration_NullBuilder() { var configuration = new Mock <IConfiguration>(); var registrar = new ConfigurationRegistrar(); Assert.Throws <ArgumentNullException>(() => registrar.RegisterConfiguration(null, configuration.Object)); }
public void RegisterConfiguration_NullConfiguration() { var builder = new ContainerBuilder(); var registrar = new ConfigurationRegistrar(); Assert.Throws <ArgumentNullException>(() => registrar.RegisterConfiguration(builder, null)); }
public void RegTo(ConfigurationRegistrar confRegistrar) { var r = new EntityTypeConfiguration<UserInfo>(); r.ToTable("UserInfo"); r.HasKey(p => p.AutoId); confRegistrar.Add<UserInfo>(r); }
/// <summary> /// Discovers all types that inherit from <see cref="System.Data.Entity.ModelConfiguration.EntityTypeConfiguration{TEntityType}" /> or /// <see cref="System.Data.Entity.ModelConfiguration.ComplexTypeConfiguration{TComplexType}" /> in named assembly, specified by <paramref name="assemblyString"/> and adds an instance /// of each discovered type to this registrar. /// </summary> /// <param name="assemblyString"> /// The assembly with configuration to be loaded or scan. /// </param> /// <remarks> /// Note that only types that are abstract or generic type definitions are skipped. Every /// type that is discovered and added must provide a parameterless constructor. /// </remarks> /// <returns>The same ConfigurationRegistrar instance so that multiple calls can be chained.</returns> public static ConfigurationRegistrar AddFromNamedAssembly(this ConfigurationRegistrar configurationRegistrar, string assemblyString) { configurationRegistrar.AddFromAssembly( Assembly.Load(assemblyString)); return(configurationRegistrar); }
/// <summary> /// Discovers all types that inherit from <see cref="System.Data.Entity.ModelConfiguration.EntityTypeConfiguration{TEntityType}" /> or /// <see cref="System.Data.Entity.ModelConfiguration.ComplexTypeConfiguration{TComplexType}" /> in assembly that contain the {TType} /// of each discovered type to this registrar. /// </summary> /// <typeparam name="TType">The type of assembly to find in.</typeparam> /// <returns>The same ConfigurationRegistrar instance so that multiple calls can be chained.</returns> public static ConfigurationRegistrar AddFromAssemblyOf <TType>(this ConfigurationRegistrar configurationRegistrar) where TType : class { configurationRegistrar .AddFromAssembly(typeof(TType).Assembly); return(configurationRegistrar); }
/// <summary> /// 将数据记录映射对象注册到当前数据访问上下文数据记录映射配置注册器中。 /// </summary> /// <param name="configurations">数据记录映射配置注册器。</param> public void RegistTo(ConfigurationRegistrar configurations) { //配置主键 HasKey(p => p.Id); KeyMapping(); PropertyMapping(); configurations.Add(this); }
public static bool IsConfigured(this ConfigurationRegistrar configurationRegistrar, Type type) { var configuredTypes = (IEnumerable <Type>)configurationRegistrar .GetType() .GetMethod("GetConfiguredTypes", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) .Invoke(configurationRegistrar, null); return(configuredTypes.Any(t => t == type)); }
public void Get_configured_types_should_return_types() { var modelConfiguration = new ModelConfiguration(); var configurationRegistrar = new ConfigurationRegistrar(modelConfiguration) .Add(new ComplexTypeConfiguration <object>()) .Add(new EntityTypeConfiguration <string>()); Assert.Equal(2, configurationRegistrar.GetConfiguredTypes().Count()); }
public void Get_configured_types_should_return_types() { var modelConfiguration = new ModelConfiguration(); var configurationRegistrar = new ConfigurationRegistrar(modelConfiguration) .Add(new ComplexTypeConfiguration<object>()) .Add(new EntityTypeConfiguration<string>()); Assert.Equal(2, configurationRegistrar.GetConfiguredTypes().Count()); }
public virtual void RegistTo(ConfigurationRegistrar configurations) { try { configurations.Add(this); } catch (InvalidOperationException) { } }
private void RegistEntityMapESOP(ConfigurationRegistrar configuration) { configuration.Add(new ESOP_DeviceMap()) .Add(new ESOP_ProductMap()) .Add(new ESOP_PublishMap()) .Add(new ESOP_DocMap()) .Add(new ESOP_DocIndexMap()) .Add(new ESOP_DocIndex_SecMap()) .Add(new ESOP_RoleDeviceMap()); }
private void RegistEntityMap(ConfigurationRegistrar configuration) { this.RegistEntityMapSystem(configuration); this.RegistEntityMapProduct(configuration); this.RegistEntityMapOrder(configuration); this.RegistEntityMapWMS(configuration); this.RegistEntityMapFile(configuration); this.RegistEntityMapESOP(configuration); this.RegistEntityMapSupplier(configuration); }
public void RegistTo(ConfigurationRegistrar configurations) { Type type = typeof(EntityTypeConfiguration <>).MakeGenericType(this.GetType()); object param = Activator.CreateInstance(type); //Type[] types = new Type[] { type }; //var v = typeof(ConfigurationRegistrar).GetMethod("Add", types); typeof(ConfigurationRegistrar).GetMethods()[1] .MakeGenericMethod(new Type[] { this.GetType() }) .Invoke(configurations, new object[] { param }); }
private void RegistEntityMapSupplier(ConfigurationRegistrar configuration) { configuration.Add(new ERP_C003_SupplierMap()) .Add(new ERP_M001_MaterialMap()) .Add(new ERP_M001_Material_SuppMap()) .Add(new SUPP_M001_PurPlanMap()) .Add(new SUPP_M001_PurPlan_MaterialMap()) .Add(new ERP_M002_BOMMap()) .Add(new ERP_M002_BOM_MaterialMap()) .Add(new ERP_C003_Supplier_FileMap()) .Add(new SUPP_M001_PurPlan_DetailMap()); }
public static void Scan(this ConfigurationRegistrar configurationRegistrar, Assembly assembly) { var types = assembly.GetTypes() .Where(t => t.BaseType != null && t.BaseType.IsGenericType && t.BaseType.GetGenericTypeDefinition() == typeof(EntityTypeConfiguration <>)); foreach (var t in types) { dynamic config = Activator.CreateInstance(t); configurationRegistrar.Add(config); } }
public static void Registe(ConfigurationRegistrar cfg) { BuildManagerWrapper .Current .PublicTypes .AsParallel() .Where(e => e != null && !e.FullName.Contains("IDBMappingRegister") && typeof(IDBMappingRegister).IsAssignableFrom(e)) .Each(e => ((IDBMappingRegister)Activator.CreateInstance(e)) .Register(cfg)); }
public static void ApplyConfigurations(this ConfigurationRegistrar configurationRegistrar) { var executingAssembly = Assembly.GetExecutingAssembly(); var configurationTypes = executingAssembly.GetTypes() .Where(t => !t.IsAbstract && t.BaseType.IsGenericType && t.BaseType.GetGenericTypeDefinition() == typeof(BaseEntityConfiguration <>)); foreach (var config in configurationTypes) { dynamic configuration = Activator.CreateInstance(config); configurationRegistrar.Add(configuration); } }
public static void AddFromNamespace(this ConfigurationRegistrar configurationRegistrar, string namespaceName) { var typesToRegister = Assembly.GetAssembly(typeof(ContextBase)).GetTypes() .Where(type => type.Namespace != null && type.Namespace.Equals(namespaceName)) .Where(type => type.BaseType.IsGenericType && (type.BaseType.GetGenericTypeDefinition() == typeof(EntityTypeConfiguration <>) || type.BaseType.GetGenericTypeDefinition() == typeof(ComplexTypeConfiguration <>))); foreach (var type in typesToRegister) { dynamic configurationInstance = Activator.CreateInstance(type); configurationRegistrar.Add(configurationInstance); } }
public void GetTypes(ConfigurationRegistrar configurationBuilder) { var types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(a => a.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IEntity)))) .ToList(); foreach (var t in types) { var Types = typeof(EntityConfigurationAll <,>); var ins = Types.MakeGenericType(t, typeof(Int32)); var Config = Activator.CreateInstance(ins) as IEntityMapper; Config.RegistTo(configurationBuilder); } }
private void RegistEntityMapProduct(ConfigurationRegistrar configuration) { configuration.Add(new ERP_M001_ProductMap()) .Add(new ERP_M001_Product_CustPackMap()) .Add(new ERP_M001_Product_FileMap()) .Add(new ERP_M001_Product_MaterialMap()) .Add(new ERP_M001_Product_ProcessFlowMap()) .Add(new ERP_M001_Product_ProdInfoMap()) .Add(new ERP_M002_MaterialMap()) .Add(new ERP_M003_ModelMap()) .Add(new ERP_M003_Model_ProductMap()) .Add(new ERP_M004_QHProductMap()) .Add(new ERP_M001_Product_PackInfoMap()) .Add(new ERP_M001_Product_SemiProductMap()) .Add(new MES_M801_Label_LMap()) .Add(new MES_M801_Label_MMap()) .Add(new MES_M801_Label_SMap()) .Add(new MES_M801_Label_L_PrintDataMap()) .Add(new MES_M801_Label_M_PrintDataMap()) .Add(new MES_M801_Label_S_PrintDataMap()) .Add(new MES_M802_Packing_DtlMap()) .Add(new MES_M802_Packing_HdMap()); }
private void RegistEntityMapOrder(ConfigurationRegistrar configuration) { configuration.Add(new MES_M001_OrderMap()) .Add(new MES_M001_Order_DetailMap()) .Add(new MES_M002_JobMap()) .Add(new MES_M002_Job_LotMap()) .Add(new MES_M003_LotTxMap()) .Add(new MES_M003_LotTx_NGMap()) .Add(new MES_M003_LotTx_NG_CloneMap()) .Add(new vw_JobReportMap()) .Add(new MES_M002_Job_Lot_ProcessMap()) .Add(new MES_M201_PlanMap()) .Add(new MES_M201_Plan_DetailMap()) .Add(new MES_M201_Plan_MaterialMap()) .Add(new MES_M201_Plan_DailyMap()) .Add(new MES_M202_TaskMap()) .Add(new MES_M202_Task_DetailMap()) .Add(new MES_M202_Task_JobLotMap()) .Add(new MES_M501_JobTxMap()) .Add(new MES_M501_JobTxDetailMap()) .Add(new MES_M501_JobTx_NGMap()) .Add(new MES_M501_JobTxProdInfoMap()); }
private void RegistEntityMapSystem(ConfigurationRegistrar configuration) { configuration.Add(new tb_Sys_MenuMap()) .Add(new tb_Sys_UserMap()) .Add(new tb_Sys_UserRoleMap()) .Add(new tb_Sys_RolesMap()) .Add(new tb_Sys_RolesRightMap()) .Add(new tb_Sys_RolesBtnMap()) .Add(new tb_Sys_ButtonMap()) .Add(new tb_Sys_RolesControlMap()) .Add(new tb_Sys_ControlsMap()) .Add(new tb_C001_CompanyMap()) .Add(new ERP_C001_CodeMap()) .Add(new ERP_C001_CodeDictionaryMap()) .Add(new ERP_C003_CustomerMap()) .Add(new ERP_C004_SupplierMap()) .Add(new ERP_C006_ProcessFlowMap()) .Add(new ERP_C005_EmployeeMap()) .Add(new ERP_C006_ProcessFlow_ProcessMap()) .Add(new ERP_C006_ProcessFlow_ProdInfoMap()) .Add(new ERP_C006_ProcessProdInfoMap()) .Add(new ERP_C009_LayoutMap()); }
private void RegistEntityMapWMS(ConfigurationRegistrar configuration) { configuration.Add(new WMS_C101_WareHouseMap()) .Add(new WMS_C102_AreaMap()) .Add(new WMS_C103_ShelfMap()) .Add(new WMS_M001_ProductMap()) .Add(new WMS_M002_StockTxMap()) .Add(new WMS_C101_InStoreMap()) .Add(new WMS_C102_InStoreDetailMap()) .Add(new WMS_C103_StockMap()) .Add(new WMS_C104_OutStoreMap()) .Add(new WMS_C105_OutStoreDetailMap()) .Add(new WMS_M101_StockTx_DataMap()) .Add(new WMS_M104_Packing_HdMap()) .Add(new WMS_M104_Packing_DetailMap()) .Add(new WMS_MatConsume_ActMatMap()) .Add(new WMS_MatConsume_ActMatDetailMap()) .Add(new WMS_MatConsume_ActMatMouthCheckMap()) .Add(new WMS_M105_MatGetMap()) .Add(new WMS_M105_MatGetDetailMap()) .Add(new WMS_M105_MatReturnMap()) .Add(new WMS_M105_MatReturnDetailMap()) .Add(new WMS_M105_MatSotreMap()); }
public void AddConfiguration(ConfigurationRegistrar registrar) { this.BuildConfiguration(); registrar.Add(this); }
public void AddConfigurationToModel(ConfigurationRegistrar configurations) { configurations.Add(this); }
public void RegistTo(ConfigurationRegistrar configurations) { configurations.Add(this); }
public void AddConfiguration(ConfigurationRegistrar registrar) { registrar.Add(this); }
public void AddFromAssembly_throw_if_assembly_is_null() { var registrar = new ConfigurationRegistrar(new ModelConfiguration()); Assert.Equal("assembly", Assert.Throws<ArgumentNullException>(() => registrar.AddFromAssembly(null)).ParamName); }
public static bool IsConfigured <T>(this ConfigurationRegistrar configurationRegistrar) { return(configurationRegistrar.IsConfigured(typeof(T))); }
public void ConfigureModel(ConfigurationRegistrar configurations) { configurations.Add(new ReadModelInfoEntityTypeConfiguration()); }