private void TypeMapSet(Transaction transaction, string key, object value) { if (!_map.TryGetValue(key, out var left)) { left = null; } var doc = transaction.Doc; var ownClientId = doc.ClientId; IContent content; if (value == null) { content = new ContentAny(new object[] { value }); } else { switch (value) { case YDoc d: content = new ContentDoc(d); break; case AbstractType at: content = new ContentType(at); break; case byte[] ba: content = new ContentBinary(ba); break; default: content = new ContentAny(new[] { value }); break; } } var newItem = new Item(new ID(ownClientId, doc.Store.GetState(ownClientId)), left, left?.LastId, null, null, this, key, content); newItem.Integrate(transaction, 0); }
public static IContent ReadItemContent(IUpdateDecoder decoder, byte info) { switch (info & Bits.Bits5) { case 0: // GC throw new Exception("GC is not ItemContent"); case 1: // Deleted return(ContentDeleted.Read(decoder)); case 2: // JSON return(ContentJson.Read(decoder)); case 3: // Binary return(ContentBinary.Read(decoder)); case 4: // String return(ContentString.Read(decoder)); case 5: // Embed return(ContentEmbed.Read(decoder)); case 6: // Format return(ContentFormat.Read(decoder)); case 7: // Type return(ContentType.Read(decoder)); case 8: // Any return(ContentAny.Read(decoder)); case 9: // Doc return(ContentDoc.Read(decoder)); default: throw new InvalidOperationException($"Content type not recognized: {info}"); } }