|
|
|
@ -206,7 +206,7 @@ namespace Volo.Abp.Cli.ServiceProxying.CSharp
|
|
|
|
|
{
|
|
|
|
|
var methodBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
var returnTypeName = GetRealTypeName(usingNamespaceList, action.ReturnValue.Type);
|
|
|
|
|
var returnTypeName = GetRealTypeName(action.ReturnValue.Type, usingNamespaceList);
|
|
|
|
|
|
|
|
|
|
if(!action.Name.EndsWith("Async"))
|
|
|
|
|
{
|
|
|
|
@ -225,7 +225,7 @@ namespace Volo.Abp.Cli.ServiceProxying.CSharp
|
|
|
|
|
|
|
|
|
|
foreach (var parameter in action.Parameters.GroupBy(x => x.Name).Select( x=> x.First()))
|
|
|
|
|
{
|
|
|
|
|
methodBuilder.Replace("<args>", $"{GetRealTypeName(usingNamespaceList, parameter.Type)} {parameter.Name}, <args>");
|
|
|
|
|
methodBuilder.Replace("<args>", $"{GetRealTypeName(parameter.Type, usingNamespaceList)} {parameter.Name}, <args>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
methodBuilder.Replace("<args>", string.Empty);
|
|
|
|
@ -249,7 +249,7 @@ namespace Volo.Abp.Cli.ServiceProxying.CSharp
|
|
|
|
|
|
|
|
|
|
foreach (var parameter in action.ParametersOnMethod)
|
|
|
|
|
{
|
|
|
|
|
methodBuilder.Replace("<args>", $"{GetRealTypeName(usingNamespaceList, parameter.Type)} {parameter.Name}, <args>");
|
|
|
|
|
methodBuilder.Replace("<args>", $"{GetRealTypeName(parameter.Type, usingNamespaceList)} {parameter.Name}, <args>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
methodBuilder.Replace("<args>", string.Empty);
|
|
|
|
@ -257,21 +257,27 @@ namespace Volo.Abp.Cli.ServiceProxying.CSharp
|
|
|
|
|
|
|
|
|
|
methodBuilder.AppendLine(" {");
|
|
|
|
|
|
|
|
|
|
var argsTemplate = "new ClientProxyRequestTypeValue" +
|
|
|
|
|
$"{Environment.NewLine} {{<args>" +
|
|
|
|
|
$"{Environment.NewLine} }}";
|
|
|
|
|
|
|
|
|
|
var args = action.ParametersOnMethod.Any() ? argsTemplate : string.Empty;
|
|
|
|
|
|
|
|
|
|
if (returnTypeName == "void")
|
|
|
|
|
{
|
|
|
|
|
methodBuilder.AppendLine($" await RequestAsync(nameof({action.Name}), <args>);");
|
|
|
|
|
methodBuilder.AppendLine($" await RequestAsync(nameof({action.Name}), {args});");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
methodBuilder.AppendLine($" return await RequestAsync<{returnTypeName}>(nameof({action.Name}), <args>);");
|
|
|
|
|
methodBuilder.AppendLine($" return await RequestAsync<{returnTypeName}>(nameof({action.Name}), {args});");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var parameter in action.ParametersOnMethod)
|
|
|
|
|
{
|
|
|
|
|
methodBuilder.Replace("<args>", $"{parameter.Name}, <args>");
|
|
|
|
|
methodBuilder.Replace("<args>", $"{Environment.NewLine} {{ typeof({GetRealTypeName(parameter.Type)}), {parameter.Name} }},<args>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
methodBuilder.Replace("<args>", string.Empty);
|
|
|
|
|
methodBuilder.Replace(",<args>", string.Empty);
|
|
|
|
|
methodBuilder.Replace(", )", ")");
|
|
|
|
|
methodBuilder.AppendLine(" }");
|
|
|
|
|
}
|
|
|
|
@ -297,7 +303,7 @@ namespace Volo.Abp.Cli.ServiceProxying.CSharp
|
|
|
|
|
return typeFullName.Substring(0, typeFullName.LastIndexOf('.'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetRealTypeName(List<string> usingNamespaceList, string typeName)
|
|
|
|
|
private string GetRealTypeName(string typeName, List<string> usingNamespaceList = null)
|
|
|
|
|
{
|
|
|
|
|
var filter = new []{"<", ",", ">"};
|
|
|
|
|
var stringBuilder = new StringBuilder();
|
|
|
|
@ -305,7 +311,11 @@ namespace Volo.Abp.Cli.ServiceProxying.CSharp
|
|
|
|
|
|
|
|
|
|
if (typeNames.All(x => !filter.Any(x.Contains)))
|
|
|
|
|
{
|
|
|
|
|
AddUsingNamespace(usingNamespaceList, typeName);
|
|
|
|
|
if (usingNamespaceList != null)
|
|
|
|
|
{
|
|
|
|
|
AddUsingNamespace(usingNamespaceList, typeName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NormalizeTypeName(typeNames.Last());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -315,7 +325,11 @@ namespace Volo.Abp.Cli.ServiceProxying.CSharp
|
|
|
|
|
{
|
|
|
|
|
if (filter.Any(x => item.Contains(x)))
|
|
|
|
|
{
|
|
|
|
|
AddUsingNamespace(usingNamespaceList, $"{fullName}.{item}".TrimStart('.'));
|
|
|
|
|
if (usingNamespaceList != null)
|
|
|
|
|
{
|
|
|
|
|
AddUsingNamespace(usingNamespaceList, $"{fullName}.{item}".TrimStart('.'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fullName = string.Empty;
|
|
|
|
|
|
|
|
|
|
if (item.Contains('<') || item.Contains(','))
|
|
|
|
|