|
@@ -12,10 +12,10 @@ namespace FlutterCodeGenerator.Map
|
|
|
internal class ServiceMap : IServiceMap
|
|
|
{
|
|
|
private List<string> _userDefinedComplexReturnTypeList;
|
|
|
- private string _serviceName;
|
|
|
-
|
|
|
private List<MethodMap> _methodMapList;
|
|
|
|
|
|
+ public string ServiceName { get; private set; }
|
|
|
+
|
|
|
public List<ComplexModelType> UsedComplexModelTypeList { get; }
|
|
|
|
|
|
public ServiceMap(Type type)
|
|
@@ -23,8 +23,8 @@ namespace FlutterCodeGenerator.Map
|
|
|
UsedComplexModelTypeList = new List<ComplexModelType>();
|
|
|
GenerateDataCache.Instance.SetCurrentServiceMap(this);
|
|
|
_methodMapList = new List<MethodMap>();
|
|
|
- var methodsList = type.GetMethods();
|
|
|
- _serviceName = type.Name[1..];
|
|
|
+ var methodsList = type.GetMethods().Where(x => !x.IsSpecialName).ToList();
|
|
|
+ ServiceName = type.Name[1..];
|
|
|
foreach (var method in methodsList)
|
|
|
{
|
|
|
var methodMap = new MethodMap(method);
|
|
@@ -41,7 +41,7 @@ namespace FlutterCodeGenerator.Map
|
|
|
{
|
|
|
if (!alreadyGeneratedList.Any(x => x.Key.ParameterType.Name == modelType.ParameterType.Name && x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace))
|
|
|
{
|
|
|
- alreadyGeneratedList.Add(modelType, _serviceName);
|
|
|
+ alreadyGeneratedList.Add(modelType, ServiceName);
|
|
|
dartString.AppendLine(modelType.GetDartString());
|
|
|
}
|
|
|
else
|
|
@@ -51,7 +51,7 @@ namespace FlutterCodeGenerator.Map
|
|
|
{
|
|
|
throw new Exception("Import Service is null");
|
|
|
}
|
|
|
- if (importService != _serviceName && !importServiceList.Contains(importService))
|
|
|
+ if (importService != ServiceName && !importServiceList.Contains(importService))
|
|
|
{
|
|
|
importServiceList.Add(importService);
|
|
|
}
|
|
@@ -94,6 +94,7 @@ namespace FlutterCodeGenerator.Map
|
|
|
var alreadyGeneratedList = GenerateDataCache.Instance.AlreadyGeneratedList;
|
|
|
foreach (var methodMap in _methodMapList)
|
|
|
{
|
|
|
+ GenerateDataCache.Instance.CurrentMethod = methodMap.MethodName;
|
|
|
string importService = null;
|
|
|
foreach (var modelType in methodMap.ParameterModelTypes)
|
|
|
{
|
|
@@ -104,7 +105,7 @@ namespace FlutterCodeGenerator.Map
|
|
|
{
|
|
|
throw new Exception("Import Service is null");
|
|
|
}
|
|
|
- if (importService != _serviceName && !importServiceList.Contains(importService))
|
|
|
+ if (importService != ServiceName && !importServiceList.Contains(importService))
|
|
|
{
|
|
|
importServiceList.Add(importService);
|
|
|
}
|
|
@@ -118,7 +119,7 @@ namespace FlutterCodeGenerator.Map
|
|
|
{
|
|
|
throw new Exception("Import Service is null");
|
|
|
}
|
|
|
- if (importService != _serviceName && !importServiceList.Contains(importService))
|
|
|
+ if (importService != ServiceName && !importServiceList.Contains(importService))
|
|
|
{
|
|
|
importServiceList.Add(importService);
|
|
|
}
|
|
@@ -133,7 +134,7 @@ namespace FlutterCodeGenerator.Map
|
|
|
{
|
|
|
throw new Exception("Import Service is null");
|
|
|
}
|
|
|
- if (importService != _serviceName && !importServiceList.Contains(importService))
|
|
|
+ if (importService != ServiceName && !importServiceList.Contains(importService))
|
|
|
{
|
|
|
importServiceList.Add(importService);
|
|
|
}
|
|
@@ -149,7 +150,7 @@ namespace FlutterCodeGenerator.Map
|
|
|
{
|
|
|
throw new Exception("Import Service is null");
|
|
|
}
|
|
|
- if (importService != _serviceName && !importServiceList.Contains(importService))
|
|
|
+ if (importService != ServiceName && !importServiceList.Contains(importService))
|
|
|
{
|
|
|
importServiceList.Add(importService);
|
|
|
}
|
|
@@ -166,7 +167,7 @@ namespace FlutterCodeGenerator.Map
|
|
|
{
|
|
|
throw new Exception("Import Service is null");
|
|
|
}
|
|
|
- if (importService != _serviceName && !importServiceList.Contains(importService))
|
|
|
+ if (importService != ServiceName && !importServiceList.Contains(importService))
|
|
|
{
|
|
|
importServiceList.Add(importService);
|
|
|
}
|
|
@@ -192,7 +193,7 @@ namespace FlutterCodeGenerator.Map
|
|
|
{
|
|
|
throw new Exception("Import Service is null");
|
|
|
}
|
|
|
- if (importService != _serviceName && !importServiceList.Contains(importService))
|
|
|
+ if (importService != ServiceName && !importServiceList.Contains(importService))
|
|
|
{
|
|
|
importServiceList.Add(importService);
|
|
|
}
|
|
@@ -208,10 +209,10 @@ namespace FlutterCodeGenerator.Map
|
|
|
}
|
|
|
|
|
|
serviceDartString.AppendLine();
|
|
|
- serviceDartString.AppendLine($"class {_serviceName} extends JsonRpcClientBase {{");
|
|
|
- serviceDartString.AppendLine($"\t{_serviceName}(");
|
|
|
+ serviceDartString.AppendLine($"class {ServiceName} extends JsonRpcClientBase {{");
|
|
|
+ serviceDartString.AppendLine($"\t{ServiceName}(");
|
|
|
serviceDartString.AppendLine("\t\tString host, {");
|
|
|
- serviceDartString.AppendLine($"\t\tString serviceName = \"I{_serviceName}\",");
|
|
|
+ serviceDartString.AppendLine($"\t\tString serviceName = \"I{ServiceName}\",");
|
|
|
serviceDartString.AppendLine("\t\tMap<String, String>? headers,");
|
|
|
serviceDartString.AppendLine("\t\tint? timeout,");
|
|
|
serviceDartString.AppendLine("\t}) : super(");
|
|
@@ -237,6 +238,7 @@ namespace FlutterCodeGenerator.Map
|
|
|
serviceDartString.AppendLine();
|
|
|
foreach (var methodMap in _methodMapList)
|
|
|
{
|
|
|
+ GenerateDataCache.Instance.CurrentMethod = methodMap.MethodName;
|
|
|
serviceDartString.AppendLine(methodMap.GetMethodDartString());
|
|
|
}
|
|
|
|
|
@@ -250,6 +252,7 @@ namespace FlutterCodeGenerator.Map
|
|
|
_userDefinedComplexReturnTypeList = new List<string>();
|
|
|
foreach (var method in _methodMapList)
|
|
|
{
|
|
|
+ GenerateDataCache.Instance.CurrentMethod = method.MethodName;
|
|
|
var veturnParameterModelType = method.ReturnParameterModelType;
|
|
|
AddUserDefinedComplexReturnType(veturnParameterModelType);
|
|
|
}
|