Beispiel #1
0
 public ApiResult <T> Create(string message, EResponseCode responseCode, T data)
 {
     return(new ApiResult <T>()
     {
         Header = new ResponseHeader(message, responseCode),
         Data = data
     });
 }
Beispiel #2
0
 // Read msg to input stream
 public override bool FromBytes(MBinaryReader mbr)
 {
     // Skip msg_id and msg_len as it has been read by outside.
     data.FromBytes(mbr);
     response_code = (EResponseCode)mbr.ReadInt16();
     if (msg_id != MSG_ID)
     {
         Console.WriteLine("Invalid msg id when parse msg type [GC_Echo_Response], expect:[16542], real:[" + msg_id + "]");
         return(false);
     }
     if (msg_len != MSG_LEN)
     {
         Console.WriteLine("Invalid msg len when parse msg type [GC_Echo_Response], expect:[276], real:[" + msg_len + "]");
         return(false);
     }
     return(true);
 }
Beispiel #3
0
 // Read msg to input stream
 public bool FromBytes(MBinaryReader mbr)
 {
     // Skip msg_id and msg_len as it has been read by outside.
     protocol_version = mbr.ReadString(protocol_version_size);
     int_param        = mbr.ReadUInt32();
     for (Int32 nElementIndex = 0; nElementIndex < int_array_size; ++nElementIndex)
     {
         int_array[nElementIndex] = mbr.ReadUInt32();
     }
     char_array = mbr.ReadString(char_array_size);
     rand_string_field.FromBytes(mbr);
     for (Int32 nElementIndex = 0; nElementIndex < rand_string_array_size; ++nElementIndex)
     {
         rand_string_array[nElementIndex].FromBytes(mbr);
     }
     enum_value = (EResponseCode)mbr.ReadInt16();
     return(true);
 }
Beispiel #4
0
 public static ActionResult Error(Exception ex, string message = "not success", List <string> messageList = null, string rederectUrl = "", EResponseCode responseCode = EResponseCode.Error401)
 {
     return(new ActionResult
     {
         message = message,
         content = null,
         success = false,
         rederectUrl = rederectUrl,
         messageList = messageList,
         ResponseCode = responseCode,
         exceptionName = ex.Message,
         exceptionStack = ex.StackTrace,
     });
 }
Beispiel #5
0
 public ResponseHeader(string message, EResponseCode responseCode)
 {
     ResponseCode = responseCode;
     Message      = message;
 }