|
@@ -1,13 +1,11 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
-using System.Threading.Tasks;
|
|
|
|
|
|
namespace FlutterCodeGenerator
|
|
|
{
|
|
|
public class ModelTypeGenerator
|
|
|
{
|
|
|
-
|
|
|
public static Dictionary<Type, int> _tempTypes = new Dictionary<Type, int>();
|
|
|
|
|
|
public static ModelType Create(Type type, string argName, bool clearTypes = false)
|
|
@@ -40,7 +38,7 @@ namespace FlutterCodeGenerator
|
|
|
{
|
|
|
return new StringModeType(argName);
|
|
|
}
|
|
|
- else if(type.BaseType.Name=="BaseParamsString")
|
|
|
+ else if (type.BaseType.Name == "BaseParamsString")
|
|
|
{
|
|
|
return new StringModeType(argName);
|
|
|
}
|
|
@@ -52,13 +50,30 @@ namespace FlutterCodeGenerator
|
|
|
{
|
|
|
return new ByteModelType(argName);
|
|
|
}
|
|
|
- else if(type==typeof(void))
|
|
|
+ else if (type == typeof(void))
|
|
|
{
|
|
|
return new VoidModelType(argName);
|
|
|
}
|
|
|
else if (type.IsEnum)
|
|
|
{
|
|
|
var modelType = new EnumModeType(type, argName);
|
|
|
+ if (!CodeGenerator.ConflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
+ {
|
|
|
+ CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name] = new Dictionary<ModelType, int>() { { modelType, 1 } };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Any(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace))
|
|
|
+ {
|
|
|
+ var index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
+ modelType.Index = index;
|
|
|
+ CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ modelType.Index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!ServiceMap.TemporaryList.Any(x => x.ParameterType == type))
|
|
|
{
|
|
|
ServiceMap.TemporaryList.Add(modelType);
|
|
@@ -74,6 +89,23 @@ namespace FlutterCodeGenerator
|
|
|
{
|
|
|
_tempTypes[type] = duplicatedTime;
|
|
|
var modelType = new UserDefinedDerivedModelType(type, argName);
|
|
|
+ if (!CodeGenerator.ConflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
+ {
|
|
|
+ CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name] = new Dictionary<ModelType, int>() { { modelType, 1 } };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Any(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace))
|
|
|
+ {
|
|
|
+ var index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
+ modelType.Index = index;
|
|
|
+ CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ modelType.Index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!ServiceMap.TemporaryList.Any(x => x.ParameterType == type))
|
|
|
{
|
|
|
ServiceMap.TemporaryList.Add(modelType);
|
|
@@ -96,6 +128,23 @@ namespace FlutterCodeGenerator
|
|
|
{
|
|
|
_tempTypes[type] = duplicatedTime;
|
|
|
var modelType = new UserDefinedGenericModelType(type, argName);
|
|
|
+ if (!CodeGenerator.ConflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
+ {
|
|
|
+ CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name] = new Dictionary<ModelType, int>() { { modelType, 1 } };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Any(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace))
|
|
|
+ {
|
|
|
+ var index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
+ modelType.Index = index;
|
|
|
+ CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ modelType.Index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!ServiceMap.TemporaryList.Any(x => x.ParameterType == type))
|
|
|
{
|
|
|
ServiceMap.TemporaryList.Add(modelType);
|
|
@@ -107,6 +156,23 @@ namespace FlutterCodeGenerator
|
|
|
{
|
|
|
_tempTypes[type] = duplicatedTime;
|
|
|
var modelType = new UserDefinedModeType(type, argName);
|
|
|
+ if (!CodeGenerator.ConflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
+ {
|
|
|
+ CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name] = new Dictionary<ModelType, int>() { { modelType, 1 } };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Any(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace))
|
|
|
+ {
|
|
|
+ var index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
+ modelType.Index = index;
|
|
|
+ CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ modelType.Index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!ServiceMap.TemporaryList.Any(x => x.ParameterType == type))
|
|
|
{
|
|
|
ServiceMap.TemporaryList.Add(modelType);
|