Browse Source

Some improved

pull/9905/head
liangshiwei 5 years ago
parent
commit
e692ee5cd6
  1. 17
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/CSharp/CSharpServiceProxyGenerator.cs
  2. 16
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxying/ClientProxyApiDescriptionFinder.cs
  3. 10
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxying/ClientProxyBase.cs
  4. 2
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxying/IClientProxyApiDescriptionFinder.cs

17
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/CSharp/CSharpServiceProxyGenerator.cs

@ -39,14 +39,16 @@ namespace Volo.Abp.Cli.ServiceProxy.CSharp
$"{Environment.NewLine} {{" +
$"{Environment.NewLine} <method placeholder>" +
$"{Environment.NewLine} }}" +
$"{Environment.NewLine}}}";
$"{Environment.NewLine}}}" +
$"{Environment.NewLine}";
private readonly string _clientProxyPartialTemplate = "// This file is part of <className>, you can customize it here" +
$"{Environment.NewLine}namespace <namespace>" +
$"{Environment.NewLine}{{" +
$"{Environment.NewLine} public partial class <className>" +
$"{Environment.NewLine} {{" +
$"{Environment.NewLine} }}" +
$"{Environment.NewLine}}}";
$"{Environment.NewLine}}}" +
$"{Environment.NewLine}";
private readonly List<string> _usingNamespaceList = new()
{
"using System;",
@ -76,7 +78,6 @@ namespace Volo.Abp.Cli.ServiceProxy.CSharp
return;
}
var projectName = Path.GetFileNameWithoutExtension(projectFilePath);
var rootNamespace = GetRootNamespace(projectFilePath);
var applicationApiDescriptionModel = await GetApplicationApiDescriptionModelAsync(args);
@ -394,7 +395,15 @@ namespace Volo.Abp.Cli.ServiceProxy.CSharp
{
var document = new XmlDocument();
document.Load(projectFilePath);
return document.SelectSingleNode("//RootNamespace").InnerText;
var rootNamespace = document.SelectSingleNode("//RootNamespace")?.InnerText;
if(rootNamespace.IsNullOrWhiteSpace())
{
rootNamespace = Path.GetFileNameWithoutExtension(projectFilePath);
}
return rootNamespace;
}
}
}

16
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxying/ClientProxyApiDescriptionFinder.cs

@ -29,9 +29,9 @@ namespace Volo.Abp.Http.Client.ClientProxying
Initial();
}
public Task<ActionApiDescriptionModel> FindActionAsync(string action)
public Task<ActionApiDescriptionModel> FindActionAsync(string methodName)
{
return Task.FromResult(ActionApiDescriptionModels[action]);
return Task.FromResult(ActionApiDescriptionModels[methodName]);
}
public Task<ApplicationApiDescriptionModel> GetApiDescriptionAsync()
@ -50,16 +50,8 @@ namespace Volo.Abp.Http.Client.ClientProxying
foreach (var actionItem in controller.Actions.Values)
{
var stringBuilder = new StringBuilder($"{appServiceType}.{actionItem.Name}(");
stringBuilder.Append("(");
foreach (var parameter in actionItem.ParametersOnMethod)
{
stringBuilder.Append($"{parameter.Type},");
}
stringBuilder.Append(")");
stringBuilder.Replace(",)", ")");
var actionKey = stringBuilder.ToString();
var actionKey = $"{appServiceType}.{actionItem.Name}.{string.Join("-", actionItem.ParametersOnMethod.Select(x => x.Type))}";
if (!ActionApiDescriptionModels.ContainsKey(actionKey))
{
ActionApiDescriptionModels.Add(actionKey, actionItem);

10
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxying/ClientProxyBase.cs

@ -47,16 +47,8 @@ namespace Volo.Abp.Http.Client.ClientProxying
private static string GetActionKey(string serviceTypeFullName, string methodName, params object[] arguments)
{
var stringBuilder = new StringBuilder($"{serviceTypeFullName}.{methodName}(");
stringBuilder.Append("(");
foreach (var parameter in arguments)
{
stringBuilder.Append($"{parameter.GetType().FullName},");
}
stringBuilder.Append(")");
stringBuilder.Replace(",)", ")");
return stringBuilder.ToString();
return $"{typeof(TService).FullName}.{methodName}.{string.Join("-", arguments.Select(x => x.GetType().FullName))}";
}
}
}

2
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxying/IClientProxyApiDescriptionFinder.cs

@ -5,7 +5,7 @@ namespace Volo.Abp.Http.Client.ClientProxying
{
public interface IClientProxyApiDescriptionFinder
{
Task<ActionApiDescriptionModel> FindActionAsync(string action);
Task<ActionApiDescriptionModel> FindActionAsync(string methodName);
Task<ApplicationApiDescriptionModel> GetApiDescriptionAsync();
}

Loading…
Cancel
Save