using System.Collections;
using System.Reflection;
using XFEExtension.NetCore.XFETransform.ObjectInfoAnalyzer;
using XFEExtension.NetCore.XFETransform.StringConverter;
namespace XFEExtension.NetCore.XFETransform;
///
/// XFE转换器
///
public class XFEConverter
{
///
/// 判断是否为基础类型
///
/// 类型
///
public static bool IsBasicType(Type type)
{
return type == typeof(string) || type == typeof(int) || type == typeof(double) || type == typeof(float) || type == typeof(decimal) || type == typeof(long) || type == typeof(short) || type == typeof(byte) || type == typeof(bool) || type == typeof(char) || type == typeof(nint) || type == typeof(uint) || type == typeof(ulong) || type == typeof(ushort) || type == typeof(sbyte) || type == typeof(DateTime) || type == typeof(TimeSpan);
}
///
/// 将基础类的文本转换为代码类型
///
/// 原文本
///
public static string ConvertBasicTypeToCodeType(string originString) => originString.ToLower().Replace("int32", "int").Replace("intptr", "nint").Replace("int64", "long").Replace("int16", "short").Replace("boolean", "bool").Replace("datetime", "DateTime");
///
/// 输出类型名称
///
/// 类型
///
public static string OutPutTypeName(Type type)
{
if (IsBasicType(type))
return ConvertBasicTypeToCodeType(type.Name);
var genericArguments = type.GetGenericArguments();
return genericArguments.Length == 0 ? type.Name : $"{type.Name.Replace($"`{genericArguments.Length}", string.Empty)}<{string.Join(", ", genericArguments.Select(x => IsBasicType(x) ? ConvertBasicTypeToCodeType(x.Name) : OutPutTypeName(x)))}>";
}
///
/// 添加并赋值父类列表
///
///
///
///
public static List