public static Doc Remove(Doc doc, Guid editID, string key, DictItem before) { var id = before.ID; var edit = new RemoveDictFieldEdit(editID, before, key); doc = doc.Apply(edit); return(doc); }
public static Doc Set(Doc doc, Guid editID, DictItem before, string key, Guid valueID) { var id = before.ID; var edit = new SetDictFieldEdit(editID, before, key, valueID); doc = doc.Apply(edit); return(doc); }
internal RemoveDictFieldEdit(Guid editID, DictItem before, string key) { ID = editID; Key = key; Before = before; var dict = before.Value.Remove(key); After = new DictItem(ItemID, dict); }
internal SetDictFieldEdit(Guid editID, DictItem before, string key, Guid valueID) { ID = editID; Key = key; ValueID = valueID; Before = before; var dict = before.Value.SetItem(key, valueID); After = new DictItem(ItemID, dict); }
public Doc DeepClone(Doc doc, out IItem clone, Dictionary <Guid, IItem>?clones = null) { clones = clones ?? new Dictionary <Guid, IItem> { }; if (clones.ContainsKey(ID)) { clone = clones[ID]; return(doc); } doc = Create(doc, out var dictID); var dictClone = (DictItem)doc[dictID]; clone = dictClone; foreach (var key in Value.Keys) { var valueID = Value[key]; var value = doc[valueID]; doc = value.DeepClone(doc, out var valueClone, clones); doc = DictItem.Set(doc, dictClone, key, valueClone.ID); } return(doc); }
public static Doc Remove(Doc doc, string key, DictItem before) { doc = doc.NewID(out var editID); return(Remove(doc, editID, key, before)); }
public static Doc Set(Doc doc, DictItem before, string key, Guid valueID) { doc = doc.NewID(out var editID); return(Set(doc, editID, before, key, valueID)); }
public CreateDictEdit(Guid editID, Guid dictID) { ID = editID; NewDictItem = new DictItem(dictID); }