|
@@ -14,6 +14,8 @@ namespace FlutterCodeGenerator
|
|
|
{
|
|
|
_tempTypes.Clear();
|
|
|
}
|
|
|
+ var usedComplexModelTypeList = GenerateDataCache.Instance.GetCurrentServiceMap().UsedComplexModelTypeList;
|
|
|
+ var conflictModelTypeList = GenerateDataCache.Instance.ConflictModelTypeList;
|
|
|
if ((_tempTypes.ContainsKey(type) && _tempTypes[type] < 2) || !_tempTypes.ContainsKey(type))
|
|
|
{
|
|
|
var duplicatedTime = 0;
|
|
@@ -69,26 +71,26 @@ namespace FlutterCodeGenerator
|
|
|
else if (type.IsEnum)
|
|
|
{
|
|
|
var modelType = new EnumModeType(type, argName);
|
|
|
- if (!CodeGenerator.ConflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
+ if (!conflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
{
|
|
|
- CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name] = new Dictionary<ModelType, int>() { { modelType, 1 } };
|
|
|
+ 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))
|
|
|
+ if (!conflictModelTypeList[modelType.ParameterType.Name].Any(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace))
|
|
|
{
|
|
|
- var index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
+ var index = conflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
modelType.Index = index;
|
|
|
- CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
+ conflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- modelType.Index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
+ modelType.Index = conflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
}
|
|
|
}
|
|
|
- if (!ServiceMap.TemporaryList.Any(x => x.ParameterType == type))
|
|
|
+ if (!usedComplexModelTypeList.Any(x => x.ParameterType == type))
|
|
|
{
|
|
|
- ServiceMap.TemporaryList.Add(modelType);
|
|
|
+ usedComplexModelTypeList.Add(modelType);
|
|
|
}
|
|
|
return modelType;
|
|
|
}
|
|
@@ -99,7 +101,7 @@ namespace FlutterCodeGenerator
|
|
|
}
|
|
|
else if (type.IsGenericType)
|
|
|
{
|
|
|
- if (type.Name == "List`1" || type.Name=="IList`1"|| type.Name == "IEnumerable`1")
|
|
|
+ if (type.Name == "List`1" || type.Name == "IList`1" || type.Name == "IEnumerable`1")
|
|
|
{
|
|
|
var modelType = new ListModelType(type, argName);
|
|
|
return modelType;
|
|
@@ -112,26 +114,26 @@ namespace FlutterCodeGenerator
|
|
|
else if (type.Name == "Nullable`1")
|
|
|
{
|
|
|
var modelType = new EnumNullableModelType(type.GetGenericArguments()[0], argName);
|
|
|
- if (!CodeGenerator.ConflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
+ if (!conflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
{
|
|
|
- CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name] = new Dictionary<ModelType, int>() { { modelType, 1 } };
|
|
|
+ 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))
|
|
|
+ if (!conflictModelTypeList[modelType.ParameterType.Name].Any(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace))
|
|
|
{
|
|
|
- var index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
+ var index = conflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
modelType.Index = index;
|
|
|
- CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
+ conflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- modelType.Index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
+ modelType.Index = conflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
}
|
|
|
}
|
|
|
- if (!ServiceMap.TemporaryList.Any(x => x.ParameterType == type))
|
|
|
+ if (!usedComplexModelTypeList.Any(x => x.ParameterType == type))
|
|
|
{
|
|
|
- ServiceMap.TemporaryList.Add(modelType);
|
|
|
+ usedComplexModelTypeList.Add(modelType);
|
|
|
}
|
|
|
return modelType;
|
|
|
}
|
|
@@ -139,31 +141,31 @@ namespace FlutterCodeGenerator
|
|
|
{
|
|
|
_tempTypes[type] = duplicatedTime;
|
|
|
var modelType = new UserDefinedGenericModelType(type, argName);
|
|
|
- if (!CodeGenerator.ConflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
+ if (!conflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
{
|
|
|
- CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name] = new Dictionary<ModelType, int>() { { modelType, 1 } };
|
|
|
+ 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))
|
|
|
+ if (!conflictModelTypeList[modelType.ParameterType.Name].Any(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace))
|
|
|
{
|
|
|
- var index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
+ var index = conflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
modelType.Index = index;
|
|
|
- CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
+ conflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- modelType.Index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
+ modelType.Index = conflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
}
|
|
|
}
|
|
|
- if (!ServiceMap.TemporaryList.Any(x => x.ParameterType == type))
|
|
|
+ if (!usedComplexModelTypeList.Any(x => x.ParameterType == type))
|
|
|
{
|
|
|
- ServiceMap.TemporaryList.Add(modelType);
|
|
|
+ usedComplexModelTypeList.Add(modelType);
|
|
|
}
|
|
|
return modelType;
|
|
|
}
|
|
|
}
|
|
|
- else if(type==typeof(object))
|
|
|
+ else if (type == typeof(object))
|
|
|
{
|
|
|
throw new Exception("Object is not supported, it should be specific type.");
|
|
|
}
|
|
@@ -171,26 +173,26 @@ namespace FlutterCodeGenerator
|
|
|
{
|
|
|
_tempTypes[type] = duplicatedTime;
|
|
|
var modelType = new UserDefinedDerivedModelType(type, argName);
|
|
|
- if (!CodeGenerator.ConflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
+ if (!conflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
{
|
|
|
- CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name] = new Dictionary<ModelType, int>() { { modelType, 1 } };
|
|
|
+ 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))
|
|
|
+ if (!conflictModelTypeList[modelType.ParameterType.Name].Any(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace))
|
|
|
{
|
|
|
- var index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
+ var index = conflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
modelType.Index = index;
|
|
|
- CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
+ conflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- modelType.Index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
+ modelType.Index = conflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
}
|
|
|
}
|
|
|
- if (!ServiceMap.TemporaryList.Any(x => x.ParameterType == type))
|
|
|
+ if (!usedComplexModelTypeList.Any(x => x.ParameterType == type))
|
|
|
{
|
|
|
- ServiceMap.TemporaryList.Add(modelType);
|
|
|
+ usedComplexModelTypeList.Add(modelType);
|
|
|
}
|
|
|
return modelType;
|
|
|
}
|
|
@@ -198,26 +200,26 @@ namespace FlutterCodeGenerator
|
|
|
{
|
|
|
_tempTypes[type] = duplicatedTime;
|
|
|
var modelType = new UserDefinedModeType(type, argName);
|
|
|
- if (!CodeGenerator.ConflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
+ if (!conflictModelTypeList.ContainsKey(modelType.ParameterType.Name))
|
|
|
{
|
|
|
- CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name] = new Dictionary<ModelType, int>() { { modelType, 1 } };
|
|
|
+ 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))
|
|
|
+ if (!conflictModelTypeList[modelType.ParameterType.Name].Any(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace))
|
|
|
{
|
|
|
- var index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
+ var index = conflictModelTypeList[modelType.ParameterType.Name].Count() + 1;
|
|
|
modelType.Index = index;
|
|
|
- CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
+ conflictModelTypeList[modelType.ParameterType.Name][modelType] = index;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- modelType.Index = CodeGenerator.ConflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
+ modelType.Index = conflictModelTypeList[modelType.ParameterType.Name].FirstOrDefault(x => x.Key.ParameterType.Namespace == modelType.ParameterType.Namespace).Value;
|
|
|
}
|
|
|
}
|
|
|
- if (!ServiceMap.TemporaryList.Any(x => x.ParameterType == type))
|
|
|
+ if (!usedComplexModelTypeList.Any(x => x.ParameterType == type))
|
|
|
{
|
|
|
- ServiceMap.TemporaryList.Add(modelType);
|
|
|
+ usedComplexModelTypeList.Add(modelType);
|
|
|
}
|
|
|
return modelType;
|
|
|
}
|
|
@@ -229,4 +231,4 @@ namespace FlutterCodeGenerator
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|