Browse Source

Remove duplicate method.

pull/14429/head
maliming 4 years ago
parent
commit
bc94119619
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 4
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs
  2. 20
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/CSharp/CSharpServiceProxyGenerator.cs

4
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs

@ -68,9 +68,9 @@ public abstract class ProxyCommandBase<T> : IConsoleCommand, ITransientDependenc
var source = commandLineArgs.Options.GetOrNull(Options.Source.Short, Options.Source.Long); var source = commandLineArgs.Options.GetOrNull(Options.Source.Short, Options.Source.Long);
var workDirectory = commandLineArgs.Options.GetOrNull(Options.WorkDirectory.Short, Options.WorkDirectory.Long) ?? Directory.GetCurrentDirectory(); var workDirectory = commandLineArgs.Options.GetOrNull(Options.WorkDirectory.Short, Options.WorkDirectory.Long) ?? Directory.GetCurrentDirectory();
var folder = commandLineArgs.Options.GetOrNull(Options.Folder.Long); var folder = commandLineArgs.Options.GetOrNull(Options.Folder.Long);
var withContracts = commandLineArgs.Options.ContainsKey(Options.WithoutContracts.Long); var withoutContracts = commandLineArgs.Options.ContainsKey(Options.WithoutContracts.Long);
return new GenerateProxyArgs(CommandName, workDirectory, module, url, output, target, apiName, source, folder, withContracts, commandLineArgs.Options); return new GenerateProxyArgs(CommandName, workDirectory, module, url, output, target, apiName, source, folder, withoutContracts, commandLineArgs.Options);
} }
public virtual string GetUsageInfo() public virtual string GetUsageInfo()

20
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/CSharp/CSharpServiceProxyGenerator.cs

@ -130,13 +130,8 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
IncludeTypes = !args.WithoutContracts IncludeTypes = !args.WithoutContracts
}); });
foreach (var controller in applicationApiDescriptionModel.Modules.Values.SelectMany(x => x.Controllers) foreach (var controller in applicationApiDescriptionModel.Modules.Values.SelectMany(x => x.Controllers).
.Where(x => x.Value.Interfaces.Any() && ServicePostfixes.Any(s => x.Value.Interfaces.Last().Type.EndsWith(s)))) Where(x => x.Value.Interfaces.Any() && ServicePostfixes.Any(s => x.Value.Interfaces.Last().Type.EndsWith(s))))
{
await GenerateClassFileAsync(args, controller.Value);
}
foreach (var controller in applicationApiDescriptionModel.Modules.Values.SelectMany(x => x.Controllers).Where(x => ShouldGenerateProxy(x.Value)))
{ {
await GenerateClassFileAsync(args, controller.Value); await GenerateClassFileAsync(args, controller.Value);
} }
@ -149,17 +144,6 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
await CreateJsonFile(args, applicationApiDescriptionModel); await CreateJsonFile(args, applicationApiDescriptionModel);
} }
private bool ShouldGenerateProxy(ControllerApiDescriptionModel controllerApiDescription)
{
if (!controllerApiDescription.Interfaces.Any())
{
return false;
}
var serviceInterface = controllerApiDescription.Interfaces.Last();
return ServicePostfixes.Any(x => serviceInterface.Type.EndsWith(x));
}
private async Task CreateJsonFile(GenerateProxyArgs args, ApplicationApiDescriptionModel applicationApiDescriptionModel) private async Task CreateJsonFile(GenerateProxyArgs args, ApplicationApiDescriptionModel applicationApiDescriptionModel)
{ {
var folder = args.Folder.IsNullOrWhiteSpace() ? ProxyDirectory : args.Folder; var folder = args.Folder.IsNullOrWhiteSpace() ? ProxyDirectory : args.Folder;

Loading…
Cancel
Save