Ejemplo n.º 1
0
 private static object GetFromDeserilize(object s)
 {
     if (s == null)
     {
         return(null);
     }
     else if (s is Newtonsoft.Json.Linq.JObject)
     {
         DSO res   = new DSO();
         var j_obj = s as Newtonsoft.Json.Linq.JObject;
         foreach (var jtoken in j_obj.Children())
         {
             res.Add(((Newtonsoft.Json.Linq.JProperty)jtoken).Name
                     , GetFromDeserilize(((Newtonsoft.Json.Linq.JProperty)jtoken).Value));
         }
         return(res);
     }
     else if (s is Newtonsoft.Json.Linq.JArray)
     {
         var j_obj = s as Newtonsoft.Json.Linq.JArray;
         LO  obj   = new LO();
         foreach (var jtoken in j_obj.Children())
         {
             obj.Add(GetFromDeserilize(jtoken));
         }
         return(obj);
     }
     else if (s is Newtonsoft.Json.Linq.JValue)
     {
         var j_obj = s as Newtonsoft.Json.Linq.JValue;
         return(j_obj.Value);
     }
     else
     {
         throw new Exception("unknown json type");
     }
 }
    public static void Main()
    {
        var lo = new LO();

        lo.Add(new OB {
            A
        });
        lo.Add(new OB {
            B
        });
        lo.DisplayResult();

        lo.Clear();
        lo.Add(new OB {
            A
        });
        lo.Add(new OB {
            NULL
        });
        lo.Add(new OB {
            B
        });
        lo.DisplayResult();

        lo.Clear();
        lo.Add(new OB {
            A
        });
        lo.Add(new OB {
            NULL
        });
        lo.Add(new OB {
            NULL
        });
        lo.Add(new OB {
            NULL
        });
        lo.Add(new OB {
            NULL
        });
        lo.Add(new OB {
            B
        });
        lo.DisplayResult();

        lo.Clear();
        lo.Add(new OB {
            A
        });
        lo.Add(new OB {
            A, B
        });
        lo.Add(new OB {
            B
        });
        lo.DisplayResult();

        lo.Clear();
        lo.Add(new OB {
            A
        });
        lo.Add(new OB {
            NULL
        });
        lo.Add(new OB {
            A
        });
        lo.DisplayResult();

        lo.Clear();
        lo.Add(new OB {
            A
        });
        lo.Add(new OB {
            A, B
        });
        lo.Add(new OB {
            A
        });
        lo.DisplayResult("Why is this not a transition but an exception?");


        lo.Clear();
        lo.Add(new OB {
            A
        });
        lo.Add(new OB {
            A, NULL
        });
        lo.Add(new OB {
            A, NULL, NULL
        });
        lo.Add(new OB {
            A
        });
        lo.DisplayResult("<A,NULL> and <A,NULL,NULL> are considered equal as per your second comment.");

        lo.Clear();
        lo.Add(new OB {
            A
        });
        lo.Add(new OB {
            A, B, NULL, C
        });
        lo.Add(new OB {
            A
        });
        lo.DisplayResult("As per your first comment");

        lo.Clear();
        lo.Add(new OB {
            A
        });
        lo.Add(new OB {
            A, B
        });
        lo.Add(new OB {
            B, A
        });
        lo.Add(new OB {
            A
        });
        lo.DisplayResult("Second and third OB are equal as per your first comment");

        lo.Clear();
        lo.Add(new OB {
            A
        });
        lo.Add(new OB {
            NULL, A
        });
        lo.Add(new OB {
            B
        });
        lo.DisplayResult();
        lo.Clear();
        lo.Add(new OB {
            A
        });
        lo.Add(new OB {
            A, B, C
        });
        lo.Add(new OB {
            B
        });
        lo.DisplayResult("Why is this not a transition as per your fourth comment?");
    }