Exemplo n.º 1
0
 public override void FromDictionary(MDictionary <MString, Message> mobj)
 {
     foreach (var kv in mobj)
     {
         if (kv.Key.Value == "Method")
         {
             Method = ((MString)kv.Value).Value;
         }
         else if (kv.Key.Value == "Session")
         {
             Session = ((MString)kv.Value).Value;
         }
         else if (kv.Key.Value == "ErrorCode")
         {
             ErrorCode = (int)((MLong)kv.Value).Value;
         }
         else if (kv.Key.Value == "Results" && kv.Value is MDictionary <MString, Message> )
         {
             MDictionary <MString, Message> dict = (MDictionary <MString, Message>)kv.Value;
             foreach (var d in dict)
             {
                 if (d.Value is MDictionary <MString, Message> )
                 {
                     Results.Add(d.Key, TryParseToObject((MDictionary <MString, Message>)d.Value));
                 }
                 else
                 {
                     Results.Add(d.Key, d.Value);
                 }
             }
         }
         else if (kv.Key.Value == "Type")
         {
             // 忽略Type
         }
         else
         {
             throw new Exception("RPCResult格式不正确 " + kv.Key + " : " + mobj.ToJson());
         }
     }
 }