Example #1
0
 //------------------------------------------------------------------------------------------------------------------------
 public void Save()
 {
     try
     {
         lock (locker)
         {
             //compile data
             var data = new Dictionary<string, string>();
             foreach (var entry in Graphs)
                 data.ForceAdd(entry.Key, entry.Value.GraphDescriptorString);
             //save
             if (Node.SaveObject(DataIdentifier_Graphs, data, Secure: true) == false)
                 DebugEx.TraceError("Could not save graphs");
         }
     }
     catch (Exception ex) { DebugEx.Assert(ex, "Unhandled exception caught"); }
 }
Example #2
0
        public static Dictionary<string, object> GetSemantics(string semantics)
        {
            //checks
            if (string.IsNullOrWhiteSpace(semantics))
                return null;
            //deserialize
            var des = semantics.FromJSON<Dictionary<string, object>>();
            var ret = new Dictionary<string, object>();
            //restore values
            foreach (var __entry in des)
            {
                try
                {
                    var key = __entry.Key;
                    var value = __entry.Value;

                    //fix values (deserialized json from object)
                    if (key == nameof(Boolean_Format))
                        value = Enum.Parse(typeof(Boolean_Format), value.ToStringInvariant());
                    else if (key == nameof(String_Case))
                        value = Enum.Parse(typeof(String_Case), value.ToStringInvariant());
                    else if (key == nameof(Decimal_Range))
                        value = (value as string).FromJSON<Decimal_Range>();
                    else if (key == nameof(Integer_Range))
                        value = (value as string).FromJSON<Integer_Range>();
                    //else if ...
                    else DebugEx.Assert("Could not deserialize semantic entry");

                    //add to final dictionary
                    if (value != null)
                        ret.ForceAdd(key, value);
                }
                catch { }
            }
            //return result
            return ret;
        }