通用类型思考

43 阅读1分钟
//多语言序号
//后期可用于前后端交互用
public class MultilingualLable
{
    //多语言,支持最大数    
    public static readonly int Max = 10;

    //中文
    public static readonly int CH = 0;
    //英文
    public static readonly int EN = 1;
}

//多语言
public class Multilingual
{
    //多语言标志,默认中文
    public int Lable { get; set; } = MultilingualLable.CH;
    //多语言值,按序号选择,序号为自定义
    public List<string> Values { get; set; }
}
//基础数据类型默认值
public class BaseTypeDefaultValue
{
    public static readonly string _bit = "0";
    public static readonly string _short = "0";

    //基数类型数组,默认值,同genericType,需赋值json|probuf序列结果

    //......
    //这个类型的默认值,可以是json序列结果,也可是probuf序列结果
    //推荐json
    public static readonly string _genericType = "";
}

//基础数据类型
public class BaseType
{
    public static readonly int _bit = 0;
    public static readonly int _short = 1;

    //......
    public static readonly int _genericType = 200;
}

//封装了基础数据类型,基础数据类型对应的数组,及默认值
public class GenericType
{
    //多语言
    //多语言的Values用于标识 标签

    //标签
    //1.可做值输入时的物理意义
    //2.可做值输出时的物理意义或者标签

    //规则:MultilingualLable中的号,对应Multilingual中Values的序列号

    public Multilingual Language { get; set; }

    //基础数据类型
    public int BaseType { get; set; }
    //数据长度,默认0,>0时为基础类型数组|集合|切片
    public int Count { get; set; } = 0;
    //默认值|实际值
    public string Value { get; set; }
}

//GenericType 应该就满足
//返回结果,多值情况,需考虑多语言实现
//多个结果时,可以在驱动中实现,反馈类型为:List<GenericType>