Пример #1
0
 public void InitCustomType(LBType customType)
 {
     IsCustomType = true;
     IsClass      = customType.IsClass;
     IsStruct     = customType.IsStruct;
     FieldTypes   = customType.FieldTypes;
 }
Пример #2
0
 /// <summary> 检查字段的有效性 | Check the validity of all custom types </summary>
 private static void CheckType(LBType type)
 {
     if (type.IsArray)
     {
         // 数组 | Array
         CheckType(type.ElementType);
     }
     else
     {
         LBBaseType baseType;
         if (TryGetBaseType(type.Type, out baseType))
         {
             // 基本类型 | Base type
             type.InitBaseType(baseType);
         }
         else
         {
             LBType customType;
             if (TryGetCustomType(type.Type, out customType))
             {
                 // 自定义结构 | Custom type
                 type.InitCustomType(customType);
             }
             else
             {
                 // 未知类型 | Unknown type
                 throw new Exception("Unknown type:\"" + type.Type + "\"");
             }
         }
     }
 }
Пример #3
0
 /// <param name="lbType">判断是否是自定义类型 并获取该类型 | If it is a custem type then get it</param>
 public static bool TryGetCustomType(string name, out LBType lbType)
 {
     if (customTypeDict.TryGetValue(name, out lbType))
     {
         return(true);
     }
     return(false);
 }
Пример #4
0
 /// <summary> 添加一个自定义类型 | Add a custom type </summary>
 /// <param name="lbType"> LB类型 | LBType</param>
 public static void AddCustomType(LBType lbType)
 {
     if (!customTypeDict.ContainsKey(lbType.Name))
     {
         customTypeDict.Add(lbType.Name, lbType);
     }
     else
     {
         string error = "Custom type [{0}] already exists.";
         error = string.Format(error, lbType.Name);
         throw new ArgumentException(error);
     }
 }
Пример #5
0
 public void InitArray(LBType elementType)
 {
     IsArray     = true;
     ElementType = elementType;
 }