public static Doc Remove(Doc doc, Guid editID, string key, FormItem before) { var id = before.ID; var edit = new RemoveFormFieldEdit(editID, before, key); doc = doc.Apply(edit); return(doc); }
public static Doc Set(Doc doc, Guid editID, FormItem before, string key, Guid valueID) { var id = before.ID; var edit = new SetFormFieldEdit(editID, before, key, valueID); doc = doc.Apply(edit); return(doc); }
internal RemoveFormFieldEdit(Guid editID, FormItem before, string key) { ID = editID; Key = key; Before = before; var kvs = Before.Value; After = (Before.ContainsKey(key) ? new FormItem(ItemID, kvs.Where(x => x.Key != key)) : Before ); }
internal SetFormFieldEdit(Guid editID, FormItem before, string key, Guid valueID) { ID = editID; Key = key; ValueID = valueID; Before = before; var kvs = Before.Value; var newKV = new KeyValuePair <string, Guid>(key, valueID); After = (Before.ContainsKey(key) ? new FormItem(ItemID, kvs.Select(kv => (kv.Key == key ? newKV : kv))) : new FormItem(ItemID, kvs.Add(newKV)) ); }
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 FormID); var FormClone = (FormItem)doc[FormID]; clone = FormClone; foreach (var kv in Value) { var key = kv.Key; var valueID = kv.Value; var value = doc[kv.Value]; doc = value.DeepClone(doc, out var valueClone, clones); doc = FormItem.Set(doc, FormClone, key, valueClone.ID); } return(doc); }
public static Doc Remove(Doc doc, string key, FormItem before) { doc = doc.NewID(out var editID); return(Remove(doc, editID, key, before)); }
public static Doc Set(Doc doc, FormItem before, string key, Guid valueID) { doc = doc.NewID(out var editID); return(Set(doc, editID, before, key, valueID)); }
public CreateFormEdit(Guid editID, Guid FormID) { ID = editID; NewFormItem = new FormItem(FormID); }