public EntitiesGeneratorProfile(EntitiesGeneratorBuilder builder) { CreateMap(builder.ProjectType, typeof(ProjectViewModel)) .SwapMemberWithOrderedMember(nameof(ProjectViewModel.Modules)) .ReverseMap(); CreateMap(builder.ProjectType, typeof(ProjectLiteViewModel)); CreateMap(builder.ModuleType, typeof(ModuleViewModel)) .SwapMemberWithOrderedMember(nameof(ModuleViewModel.Items)) .SwapMemberWithOrderedMember(nameof(ModuleViewModel.ItemsRelationships)) .ReverseMap(); CreateMap(builder.ModuleType, typeof(ModuleLiteViewModel)); CreateMap(builder.ItemType, typeof(ItemViewModel)) .SwapMemberWithOrderedMember(nameof(ItemViewModel.FeatureSettings)) .ReverseMap(); CreateMap(builder.ItemType, typeof(ItemLiteViewModel)); CreateMap(builder.FeatureSettingType, typeof(FeatureSettingViewModel)) .ReverseMap(); CreateMap(builder.FeatureSettingType, typeof(FeatureSettingLiteViewModel)); CreateMap(builder.ItemsRelationshipType, typeof(ItemsRelationshipViewModel)) .ReverseMap(); CreateMap(builder.ItemsRelationshipType, typeof(ItemsRelationshipLiteViewModel)); var internalMethod = GetType().GetMethod("ConstructorInternal", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); if (internalMethod != null) { internalMethod.Invoke(this, new object[] { builder }); } }
public static EntitiesGeneratorBuilder AddSealedModels(this EntitiesGeneratorBuilder builder) { var services = builder.Services; services.TryAddScoped( typeof(IProjectAccessor <>).MakeGenericType(builder.ProjectType), typeof(ProjectAccessor)); services.TryAddScoped( typeof(IModuleAccessor <,>).MakeGenericType(builder.ModuleType, builder.ProjectType), typeof(ModuleAccessor)); services.TryAddScoped( typeof(IItemAccessor <,>).MakeGenericType(builder.ItemType, builder.ModuleType), typeof(ItemAccessor)); services.TryAddScoped( typeof(IFeatureSettingAccessor <,>).MakeGenericType(builder.FeatureSettingType, builder.ItemType), typeof(FeatureSettingAccessor)); services.TryAddScoped( typeof(IItemsRelationshipAccessor <,>).MakeGenericType(builder.ItemsRelationshipType, builder.ModuleType), typeof(ItemsRelationshipAccessor)); var internalMethod = typeof(SealedModelsEntitiesGeneratorBuilderExtensions).GetMethod("AddSealedModelsInternal", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); if (internalMethod != null) { internalMethod.Invoke(null, new object[] { builder }); } return(builder); }
public static EntitiesGeneratorBuilder AddDefaultViewModels(this EntitiesGeneratorBuilder builder) { builder.Services.AddAutoMapper(config => { config.AddProfile(builder.GetDefaultViewModelsProfile()); }, Array.Empty <Assembly>()); return(builder); }
protected virtual void ConstructorInternal(EntitiesGeneratorBuilder builder) { CreateMap(builder.FeatureSettingType, typeof(FeatureSettingLiteViewModel)) .IncludeAllDerived() .ReverseMap() .IncludeAllDerived(); CreateMap(builder.DomainSpecificTypes[nameof(EntityFeatureSettingViewModel).Replace("ViewModel", string.Empty)], typeof(EntityFeatureSettingViewModel)) .ReverseMap(); CreateMap(builder.DomainSpecificTypes[nameof(TimeTrackedEntityFeatureSettingViewModel).Replace("ViewModel", string.Empty)], typeof(TimeTrackedEntityFeatureSettingViewModel)) .ReverseMap(); CreateMap(builder.DomainSpecificTypes[nameof(CodeBasedEntityFeatureSettingViewModel).Replace("ViewModel", string.Empty)], typeof(CodeBasedEntityFeatureSettingViewModel)) .ReverseMap(); CreateMap(builder.DomainSpecificTypes[nameof(NameBasedEntityFeatureSettingViewModel).Replace("ViewModel", string.Empty)], typeof(NameBasedEntityFeatureSettingViewModel)) .ReverseMap(); CreateMap(builder.DomainSpecificTypes[nameof(ScopedNameBasedEntityFeatureSettingViewModel).Replace("ViewModel", string.Empty)], typeof(ScopedNameBasedEntityFeatureSettingViewModel)) .ReverseMap(); CreateMap(builder.DomainSpecificTypes[nameof(ReadableIdEntityFeatureSettingViewModel).Replace("ViewModel", string.Empty)], typeof(ReadableIdEntityFeatureSettingViewModel)) .ReverseMap(); CreateMap(builder.DomainSpecificTypes[nameof(OnOffEntityFeatureSettingViewModel).Replace("ViewModel", string.Empty)], typeof(OnOffEntityFeatureSettingViewModel)) .ReverseMap(); CreateMap(builder.DomainSpecificTypes[nameof(ChildEntityFeatureSettingViewModel).Replace("ViewModel", string.Empty)], typeof(ChildEntityFeatureSettingViewModel)) .ReverseMap(); CreateMap(builder.DomainSpecificTypes[nameof(PreprocessedEntityFeatureSettingViewModel).Replace("ViewModel", string.Empty)], typeof(PreprocessedEntityFeatureSettingViewModel)) .ReverseMap(); CreateMap(builder.DomainSpecificTypes[nameof(InterModuleEntityFeatureSettingViewModel).Replace("ViewModel", string.Empty)], typeof(InterModuleEntityFeatureSettingViewModel)) .ReverseMap(); CreateMap(builder.ItemsRelationshipType, typeof(ItemsRelationshipLiteViewModel)) .IncludeAllDerived() .ReverseMap() .IncludeAllDerived(); CreateMap(builder.DomainSpecificTypes[nameof(OneToManyItemsRelationshipViewModel).Replace("ViewModel", string.Empty)], typeof(OneToManyItemsRelationshipViewModel)) .ReverseMap(); CreateMap(builder.DomainSpecificTypes[nameof(ManyToManyItemsRelationshipViewModel).Replace("ViewModel", string.Empty)], typeof(ManyToManyItemsRelationshipViewModel)) .ReverseMap(); }
private static EntitiesGeneratorBuilder AddSealedModelsInternal(this EntitiesGeneratorBuilder builder) { builder.DomainSpecificTypes.Add(nameof(EntityFeatureSetting), typeof(EntityFeatureSetting)); builder.DomainSpecificTypes.Add(nameof(TimeTrackedEntityFeatureSetting), typeof(TimeTrackedEntityFeatureSetting)); builder.DomainSpecificTypes.Add(nameof(CodeBasedEntityFeatureSetting), typeof(CodeBasedEntityFeatureSetting)); builder.DomainSpecificTypes.Add(nameof(NameBasedEntityFeatureSetting), typeof(NameBasedEntityFeatureSetting)); builder.DomainSpecificTypes.Add(nameof(ScopedNameBasedEntityFeatureSetting), typeof(ScopedNameBasedEntityFeatureSetting)); builder.DomainSpecificTypes.Add(nameof(ReadableIdEntityFeatureSetting), typeof(ReadableIdEntityFeatureSetting)); builder.DomainSpecificTypes.Add(nameof(OnOffEntityFeatureSetting), typeof(OnOffEntityFeatureSetting)); builder.DomainSpecificTypes.Add(nameof(ChildEntityFeatureSetting), typeof(ChildEntityFeatureSetting)); builder.DomainSpecificTypes.Add(nameof(PreprocessedEntityFeatureSetting), typeof(PreprocessedEntityFeatureSetting)); builder.DomainSpecificTypes.Add(nameof(InterModuleEntityFeatureSetting), typeof(InterModuleEntityFeatureSetting)); builder.DomainSpecificTypes.Add(nameof(OneToManyItemsRelationship), typeof(OneToManyItemsRelationship)); builder.DomainSpecificTypes.Add(nameof(ManyToManyItemsRelationship), typeof(ManyToManyItemsRelationship)); return(builder); }
public static EntitiesGeneratorBuilder AddAspNetCore(this EntitiesGeneratorBuilder builder) { var services = builder.Services; // Hosting doesn't add IHttpContextAccessor by default services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddScoped( typeof(IProjectManager <>).MakeGenericType(builder.ProjectType), typeof(AspNetProjectManager <>).MakeGenericType(builder.ProjectType)); services.AddScoped( typeof(IModuleManager <,>).MakeGenericType(builder.ModuleType, builder.ProjectType), typeof(AspNetModuleManager <,>).MakeGenericType(builder.ModuleType, builder.ProjectType)); services.AddScoped( typeof(IItemManager <,>).MakeGenericType(builder.ItemType, builder.ModuleType), typeof(AspNetItemManager <,>).MakeGenericType(builder.ItemType, builder.ModuleType)); services.AddScoped( typeof(IFeatureSettingManager <,>).MakeGenericType(builder.FeatureSettingType, builder.ItemType), typeof(AspNetFeatureSettingManager <,>).MakeGenericType(builder.FeatureSettingType, builder.ItemType)); services.AddScoped( typeof(IItemsRelationshipManager <,>).MakeGenericType(builder.ItemsRelationshipType, builder.ModuleType), typeof(AspNetItemsRelationshipManager <,>).MakeGenericType(builder.ItemsRelationshipType, builder.ModuleType)); var internalMethod = typeof(AspNetEntitiesGeneratorBuilderExtensions).GetMethod("AddAspNetCoreInternal", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); if (internalMethod != null) { internalMethod.Invoke(null, new object[] { builder }); } return(builder); }
public static EntitiesGeneratorBuilder AddEntityFrameworkCoreWithSealedModels <TContext>(this EntitiesGeneratorBuilder builder) where TContext : DbContext { var services = builder.Services; var contextType = typeof(TContext); services.TryAddScoped( typeof(IProjectStore <>).MakeGenericType(builder.ProjectType), typeof(ProjectStore <>).MakeGenericType(contextType)); services.TryAddScoped( typeof(IModuleStore <,>).MakeGenericType(builder.ModuleType, builder.ProjectType), typeof(ModuleStore <>).MakeGenericType(contextType)); services.TryAddScoped( typeof(IItemStore <,>).MakeGenericType(builder.ItemType, builder.ModuleType), typeof(ItemStore <>).MakeGenericType(contextType)); services.TryAddScoped( typeof(IFeatureSettingStore <,>).MakeGenericType(builder.FeatureSettingType, builder.ItemType), typeof(FeatureSettingStore <>).MakeGenericType(contextType)); services.TryAddScoped( typeof(IItemsRelationshipStore <,>).MakeGenericType(builder.ItemsRelationshipType, builder.ModuleType), typeof(ItemsRelationshipStore <>).MakeGenericType(contextType)); var internalMethod = typeof(EntityFrameworkCoreEntitiesGeneratorBuilderExtensions).GetMethod("AddEntityFrameworkCoreWithSealedModelsInternal", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); if (internalMethod != null) { internalMethod = internalMethod.MakeGenericMethod(typeof(TContext)); internalMethod.Invoke(null, new object[] { builder }); } return(builder); }
public static Profile GetDefaultViewModelsProfile(this EntitiesGeneratorBuilder builder) => new EntitiesGeneratorProfile(builder);