public static Object getDataWithPrefix(byte[] prefix) { int count = 0; Map <byte[], BigInteger> map = new Map <byte[], BigInteger>(); Iterator <byte[], byte[]> iterator = Storage.Find(Storage.CurrentContext, prefix); while (iterator.Next()) { if (iterator.Key.Range(0, prefix.Length) == prefix) { count++; byte[] rawKey = iterator.Key; byte[] addr = rawKey.Range(prefix.Length, rawKey.Length - prefix.Length); BigInteger value = iterator.Value.AsBigInteger(); map[addr] = value; } } var objs = new Object[count]; if (count == 0) { return(objs); } int index = 0; foreach (byte[] addr in map.Keys) { NodeObj obj = new NodeObj(); obj.addr = addr; obj.value = map[addr]; objs[index] = obj; index++; } return(objs); }
public static Object getDataWithPara(string para) { Map <byte[], BigInteger> map = getObjectWithKey(para); var array = new Object[map.Values.Length]; int index = 0; foreach (byte[] addr in map.Keys) { NodeObj obj = new NodeObj(); obj.value = map[addr]; obj.addr = addr; array[index] = obj; index++; } return(array); }
public void VisualizeGraphWithCycle() { var visualizer = new ObjectGraphVisualizer(); IData data; var root = new NodeObj(); root.next = new NodeObj(); root.next.next = root; var dot = visualizer.Visualize(root, out data); Assert.That(dot, Does.Contain( "1 [ label=\"YetiCommon.Tests.Util.NodeObj\" id=\"dark googlegreen\" ];")); Assert.That(dot, Does.Contain("2 [ label=\"YetiCommon.Tests.Util.NodeObj\" ];")); Assert.That(dot, Does.Contain("1 -> 2 [ label=\"next\" ];")); Assert.That(dot, Does.Contain("2 -> 1 [ label=\"next\" ];")); Assert.That(data.RootObject, Is.EqualTo(root)); Assert.That(data.InternalNodes, Is.EquivalentTo(new object[] { root, root.next })); Assert.That(data.TruncatedNodes, Is.Empty); Assert.That(data.LeafNodes, Is.Empty); }