public static FoxBlob FromJson(string json) { var blob = new FoxBlob(); blob.ReadJson(json); return(blob); }
public FoxBlob Clone() { var clone = new FoxBlob(); clone.ReadJson(ToString()); return(clone); }
public void SetBlob(string key, FoxBlob value) { ValidateKey(key); if (_entries[key].GetValue() is FoxBlob blob) { blob.Dispose(); } _entries[key].SetBlob(value); }
public FoxBlob GetBlob(FoxBlob _default) { Validate(BlobKind.Blob); if (_value is FoxBlob result) { return(result); } return(_default); }
private static void GetJsonData(FoxBlob level, IDictionary <string, object> current) { foreach (var entry in level.Entries.OrderBy(x => x.Key)) { if (entry.Value.Kind != BlobKind.Blob) { current.Add(entry.Key, entry.Value.GetValue()); } else { var data = new Dictionary <string, object>(); GetJsonData(entry.Value.GetBlob(), data); current.Add(entry.Key, data); } } }
public void SetBlob(FoxBlob value) { Kind = BlobKind.Blob; _value = value; }
private void Parse(object data, FoxBlob level) { if (data is Dictionary <string, object> == false) { return; } foreach (var entry in (Dictionary <string, object>)data) { if (entry.Value is JObject obj) { Parse(obj.ToObject <Dictionary <string, object> >(), level.FetchBlob(entry.Key)); continue; } if (entry.Value is JArray list) { var pList = list.Cast <object>().ToList(); if (level.Contains(entry.Key)) { var en = level.GetList <object>(entry.Key); pList.AddRange(en); level.SetList(entry.Key, pList); } else { level.SetList(entry.Key, pList); } pList.Clear(); continue; } if (entry.Value == null) { level.SetString(entry.Key, null); continue; } if (entry.Value is string str) { level.SetString(entry.Key, str); continue; } if (entry.Value is long lon) { level.SetNumber(entry.Key, lon); continue; } if (entry.Value is bool bol) { level.SetBool(entry.Key, bol); continue; } if (entry.Value is double dou) { level.SetDouble(entry.Key, dou); continue; } } }
public void MergeFrom(FoxBlob blob) { ReadJson(blob.ToString()); }
public FoxBlob GetBlob(string key, FoxBlob _default) { return(!_entries.ContainsKey(key) ? _default : _entries[key].GetBlob(_default)); }