Browse Source

Studio module-installing: Added AddEfCoreConfigurationMethodStep

pull/10363/head
Yunus Emre Kalkan 4 years ago
parent
commit
b2f97f140f
  1. 7
      modules/identity/src/Volo.Abp.Identity.Installer/Volo/Abp/Identity/IdentityInstallerPipelineBuilder.cs
  2. 18
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/EfCoreConfigurationMethodDeclaration.cs
  3. 14
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingContext.cs
  4. 8
      studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineBuilderBase.cs
  5. 43
      studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AddEfCoreConfigurationMethodStep.cs

7
modules/identity/src/Volo.Abp.Identity.Installer/Volo/Abp/Identity/IdentityInstallerPipelineBuilder.cs

@ -11,6 +11,13 @@ namespace Volo.Abp.Identity
{
public async Task<ModuleInstallingPipeline> BuildAsync(ModuleInstallingContext context)
{
context.AddEfCoreConfigurationMethodDeclaration(
new EfCoreConfigurationMethodDeclaration(
"Volo.Abp.Identity.EntityFrameworkCore",
"ConfigureIdentity"
)
);
return GetBasePipeline(context);
}
}

18
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/EfCoreConfigurationMethodDeclaration.cs

@ -0,0 +1,18 @@
using JetBrains.Annotations;
namespace Volo.Abp.Studio.ModuleInstalling
{
public class EfCoreConfigurationMethodDeclaration
{
public string Namespace { get; }
public string MethodName { get; }
public EfCoreConfigurationMethodDeclaration([NotNull] string nameSpace, [NotNull] string methodName)
{
Namespace = Check.NotNullOrEmpty(nameSpace, nameof(nameSpace));
MethodName = Check.NotNullOrEmpty(methodName, nameof(methodName));
}
}
}

14
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingContext.cs

@ -18,6 +18,8 @@ namespace Volo.Abp.Studio.ModuleInstalling
public string Version { get; set; }
public List<EfCoreConfigurationMethodDeclaration> EfCoreConfigurationMethodDeclarations { get; }
public List<PackageInfo> TargetModulePackages { get; protected set; }
public List<PackageInfoWithAnalyze> ReferenceModulePackages { get; protected set; }
@ -45,9 +47,21 @@ namespace Volo.Abp.Studio.ModuleInstalling
TargetModulePackages = new List<PackageInfo>();
ReferenceModulePackages = new List<PackageInfoWithAnalyze>();
EfCoreConfigurationMethodDeclarations = new List<EfCoreConfigurationMethodDeclaration>();
ServiceProvider = Check.NotNull(serviceProvider, nameof(serviceProvider));
}
public void AddEfCoreConfigurationMethodDeclaration(params EfCoreConfigurationMethodDeclaration[] methodNames)
{
foreach (var methodName in methodNames)
{
Check.NotNull(methodName, nameof(methodName));
EfCoreConfigurationMethodDeclarations.Add(methodName);
}
}
public void SetReferenceModulePackages([NotNull] List<PackageInfoWithAnalyze> referenceModulePackages)
{
Check.NotNull(referenceModulePackages, nameof(referenceModulePackages));

8
studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineBuilderBase.cs

@ -1,4 +1,5 @@
using Volo.Abp.Studio.ModuleInstalling.Steps;
using System.Linq;
using Volo.Abp.Studio.ModuleInstalling.Steps;
namespace Volo.Abp.Studio.ModuleInstalling
{
@ -20,6 +21,11 @@ namespace Volo.Abp.Studio.ModuleInstalling
pipeline.Add(new PackageReferencingStep());
if (context.EfCoreConfigurationMethodDeclarations.Any())
{
pipeline.Add(new AddEfCoreConfigurationMethodStep());
}
return pipeline;
}
}

43
studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/AddEfCoreConfigurationMethodStep.cs

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Cli.ProjectModification;
using Volo.Abp.Studio.Packages;
using Volo.Abp.Studio.Packages.Modifying;
using Volo.Abp.Studio.Analyzing.Models.Module;
namespace Volo.Abp.Studio.ModuleInstalling.Steps
{
public class AddEfCoreConfigurationMethodStep : ModuleInstallingPipelineStep
{
public override async Task ExecuteAsync(ModuleInstallingContext context)
{
var efCoreProject = context.TargetModulePackages.FirstOrDefault(p => p.Role == PackageTypes.EntityFrameworkCore);
if (efCoreProject == null)
{
return;
}
var efCoreProjectCsprojPath = efCoreProject.Path.RemovePostFix(PackageConsts.FileExtension) + ".csproj";
var _derivedClassFinder = context.ServiceProvider.GetRequiredService<DerivedClassFinder>();
var _dbContextFileBuilderConfigureAdder = context.ServiceProvider.GetRequiredService<DbContextFileBuilderConfigureAdder>();
var dbContextFile = _derivedClassFinder.Find(efCoreProjectCsprojPath, "AbpDbContext").FirstOrDefault();
if (dbContextFile == null)
{
return;
}
foreach (var declaration in context.EfCoreConfigurationMethodDeclarations)
{
_dbContextFileBuilderConfigureAdder.Add(dbContextFile, declaration.Namespace + ":" + declaration.MethodName);
}
}
}
}
Loading…
Cancel
Save