コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
            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
                    );
            }
コード例 #4
0
            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))
                    );
            }
コード例 #5
0
        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);
        }
コード例 #6
0
 public static Doc Remove(Doc doc, string key, FormItem before)
 {
     doc = doc.NewID(out var editID);
     return(Remove(doc, editID, key, before));
 }
コード例 #7
0
 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));
 }
コード例 #8
0
 public CreateFormEdit(Guid editID, Guid FormID)
 {
     ID          = editID;
     NewFormItem = new FormItem(FormID);
 }