Ejemplo n.º 1
0
 public static bool Deserialize(string orig, Deep deep, out GunV1_0 deserialized)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(orig, NAME, deep, out rest))
     {
         if (rest.Length == 6)
         {
             int[]    paramsInt;
             string[] zonesString;
             if (Parser.TryParse(new int[] { 0, 1, 2, 3, 4 }, rest, out paramsInt) &&
                 ProtocolV1_0Utils.Deserialize(rest[5], out zonesString, deep.NEXT))
             {
                 ZoneV1_0[] zones = new ZoneV1_0[zonesString.Length];
                 for (int i = 0; i < zones.Length; i++)
                 {
                     if (!ZoneV1_0.Deserialize(zonesString[i], deep.NEXT.NEXT, out zones[i]))
                     {
                         deserialized = null;
                         return(false);
                     }
                 }
                 deserialized = new GunV1_0(paramsInt[0], paramsInt[1], paramsInt[2], paramsInt[3], paramsInt[4], zones);
                 return(true);
             }
         }
     }
     deserialized = null;
     return(false);
 }
 public override bool IsTransferable(ACommand c)
 {
     if (c is GetGunsAnswerCommand)
     {
         var       c2   = (GetGunsAnswerCommand)c;
         GunV1_0[] guns = new GunV1_0[c2.GUNS.Length];
         for (int i = 0; i < guns.Length; i++)
         {
             guns[i] = new GunV1_0(c2.GUNS[i]);
         }
         cache.Cached(c, new GetGunsAnswerCommandV1_0(guns));
         return(true);
     }
     return(false);
 }
 public override bool IsDeserializeable(string s)
 {
     s = s.Trim();
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, NAME, ProtocolV1_0Utils.DEFAULT, out rest))
     {
         if (rest.Length == 1 && ProtocolV1_0Utils.Deserialize(rest[0], out rest, ProtocolV1_0Utils.DEFAULT.NEXT))
         {
             GunV1_0[] guns = new GunV1_0[rest.Length];
             for (int i = 0; i < guns.Length; i++)
             {
                 if (!GunV1_0.Deserialize(rest[i], ProtocolV1_0Utils.DEFAULT.NEXT.NEXT, out guns[i]))
                 {
                     return(false);
                 }
             }
             cache.Cached(s, new GetGunsAnswerCommandV1_0(guns));
             return(true);
         }
     }
     return(false);
 }