public void EncodeAndDecodeStrings() { Document[] docs = GetDocuments(2); Text text1 = docs[0].GetText("text"); Text text2 = docs[1].GetText("text"); docs[0].Update += (doc, data) => { docs[1].ApplyUpdate(data); }; docs[0].Transact((transaction) => { text1.InsertTextFunc(0, "Where is clothes?", transaction); text1.InsertTextFunc(9, "my ", transaction); }); docs[0].Transact((transaction) => { text1.InsertTextFunc(0, "Yo Obama! ", transaction); }); Assert.Equal("Yo Obama! Where is my clothes?", text2.ToString()); }
public void EncodeAndDecodeArrays() { Document[] docs = GetDocuments(2); Array array1 = docs[0].GetArray("array"); Array array2 = docs[1].GetArray("array"); docs[0].Update += (doc, data) => { docs[1].ApplyUpdate(data); }; docs[0].Transact((transaction) => { array1.Insert(0, new ContentBinary(BitConverter.GetBytes(1))); array1.Insert(1, new ContentBinary(BitConverter.GetBytes(3))); }); docs[0].Transact((transaction) => { array1.Insert(1, new ContentBinary(BitConverter.GetBytes(2))); }); Assert.Equal(1, BitConverter.ToInt32((array2[0] as ContentBinary).data)); Assert.Equal(2, BitConverter.ToInt32((array2[1] as ContentBinary).data)); Assert.Equal(3, BitConverter.ToInt32((array2[2] as ContentBinary).data)); }
public ContentBinary ReadContentBinary() { int length = ReadInt(); byte[] value = data.Skip(index).Take(length).ToArray(); index += length; return(new ContentBinary(value)); }
public CollabBinding(Controller controller) { Controller = controller; document = new Document(); nodes = document.AddArray("nodes"); edges = document.AddArray("edges"); InitConnection(); }
public static MSAGLPoint DataToPoint(byte[] data) { return(new MSAGLPoint { X = BitConverter.ToDouble(data, 0), Y = BitConverter.ToDouble(data, 8) }); }
private void Nodes_Update(object sender, string[] changedKeys) { while (nodes.length > Controller.UINodes.Count) { var diff = nodes.length - Controller.UINodes.Count; Map newNode = nodes[nodes.length - diff] as Map; AddNode(newNode); } }
private void Edges_Update(object sender, string[] changedKeys) { while (edges.length > Controller.Graph.EdgeCount) { var diff = edges.length - Controller.Graph.EdgeCount; Map newEdge = edges[edges.length - diff] as Map; AddEdge(newEdge); } }
public Array AddArray(string name) { if (!share.ContainsKey(name)) { Array array = new Array(); array.docName = name; array.Integrate(this, null); share[name] = array; return(array); } throw new Exception($"{name} is already defined"); }
public void ApplyUpdate(byte[] data) { if (data.Length == 0) { return; } Decoder decoder = new Decoder(data, this); Transact((transaction) => { decoder.ReadItems(transaction, store); }); }
public void CreateArrayDoc() { Document doc = GetDocuments(1)[0]; Array array = doc.GetArray("array"); array.Insert(0, new ContentBinary(BitConverter.GetBytes(1))); array.Insert(1, new ContentBinary(BitConverter.GetBytes(3))); array.Insert(1, new ContentBinary(BitConverter.GetBytes(2))); Assert.Equal(1, BitConverter.ToInt32((array[0] as ContentBinary).data)); Assert.Equal(2, BitConverter.ToInt32((array[1] as ContentBinary).data)); Assert.Equal(3, BitConverter.ToInt32((array[2] as ContentBinary).data)); }
public Decoder(byte[] data, Document doc) { this.data = data; this.doc = doc; index = 0; }