Пример #1
0
 public void Refresh()
 {
     lock (this)
     {
         if (Events.Length > 10000)
         {
             Events.Clear();
         }
         using (var list = CollectionObjectPool <string> .AllocList())
         {
             this.Runner.PopLogs(list);
             foreach (var e in list)
             {
                 Events.AppendLine(e);
             }
         }
         var colums = Runner.Columns;
         for (int i = 1; i < colums.Length; i++)
         {
             if (this.SubItems[i].Text != colums[i])
             {
                 this.SubItems[i].Text = colums[i];
             }
         }
         if (Client.GameClient.IsConnected == false)
         {
             this.ForeColor = Color.Gray;
         }
         else
         {
             this.ForeColor = Color.Black;
         }
     }
 }
Пример #2
0
 public ResponseErrorCodes(Type type)
 {
     this.FullName = type.ToTypeDefineFullName();
     using (var list = CollectionObjectPool <ErrorCode> .AllocList())
     {
         var fields = PropertyUtil.GetFields(type);
         foreach (var field in fields)
         {
             if (field.IsLiteral && field.IsStatic && field.FieldType == typeof(int))
             {
                 var attr = PropertyUtil.GetAttribute <MessageCodeAttribute>(field);
                 if (attr != null)
                 {
                     var code = (int)field.GetValue(null);
                     list.Add(new ErrorCode(type, code, attr));
                 }
             }
         }
         foreach (var error_code in list)
         {
             try
             {
                 error_codes.TryAdd(error_code.Code, error_code);
             }
             catch
             {
                 throw new Exception($"AddErrorCodeError: Type={type.FullName} Code={error_code.Code}");
             }
         }
     }
 }
Пример #3
0
 public ErrorCode(Type owner_type, int code, MessageCodeAttribute attr)
 {
     this.code            = code;
     this.owner_attribute = attr;
     this.message         = attr.Message;
     if (attr.Args != null)
     {
         using (var list = CollectionObjectPool <FieldInfo> .AllocList(attr.Args.Length))
         {
             foreach (var fileName in attr.Args)
             {
                 var field = owner_type.GetField(fileName);
                 if (field == null)
                 {
                     throw new Exception(string.Format("错误代码文字字段不存在: Type={0} Code={1} FieldName={2}", owner_type, code, fileName));
                 }
                 list.Add(field);
             }
             this.args     = list.ToArray();
             this.args_str = new object[args.Length];
         }
     }
 }