Ejemplo n.º 1
0
 public void SetDSOInfo(DSO item)
 {
     label_description.Text =
         $" {Locales.Info_Name} {item.Name} \n " +
         $"{Locales.Info_Designations} {item.designations}";
     label_characteristics.Text =
         $"{Locales.Info_Type} {item.type} \n " +
         $"{Locales.Info_Constellation} {item.Constellation} \n " +
         $"{Locales.Info_Magnitude} {item.mag} \n " +
         $"{Locales.Info_Diameter} {item.size} {Locales.Info_LY}";
     imagee.Source = item.pic;
 }
Ejemplo n.º 2
0
 public static void SetElement <T>(this Dictionary <string, object> obj, T value, params string[] p)
 {
     if (obj == null || p.Length == 0 || p == null)
     {
         return;
     }
     if (p.Length == 1)
     {
         obj.AddOrUpdate(p[0], value);
     }
     else
     {
         object o = obj.ContainsKey(p[0]) ? obj[p[0]] : null;
         if (!(o is Dictionary <string, object>))
         {
             o = new DSO();
             obj.AddOrUpdate(p[0], o);
         }
         var p2 = p.ToList();
         p2.RemoveAt(0);
         (o as Dictionary <string, object>).SetElement(value, p2.ToArray());
     }
 }
Ejemplo n.º 3
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");
     }
 }