private static void RoundtripTest(IDagNode a) { var ms = new MemoryStream(); a.Write(ms); ms.Position = 0; var b = new DagNode(ms); Assert.AreEqual(a.DataBytes, b.DataBytes); Assert.AreEqual(a.ToArray(), b.ToArray()); Assert.AreEqual(a.Links.Count(), b.Links.Count()); foreach (var _ in a.Links.Zip(b.Links, (first, second) => { Assert.AreEqual(first.Id, second.Id); Assert.AreEqual(first.Name, second.Name); Assert.AreEqual(first.Size, second.Size); return(first); }).ToArray()) { using (var first = a.DataStream) { using (var second = b.DataStream) { Assert.AreEqual(first.Length, second.Length); for (var i = 0; i < first.Length; ++i) { Assert.AreEqual(first.ReadByte(), second.ReadByte()); } } } } }
public void SetInput(int index, IDagNode node) { //todo: what does c# do on out of bounds? while (_inputArray.Count <= index) { _inputArray.Add(null); } _inputArray[index] = node; }
/// <summary> /// Creates a new instance of the <see cref="ChunkedStream" /> class with /// the specified <see cref="IBlockApi" /> and <see cref="DagNode" />. /// </summary> /// <param name="blockService"></param> /// <param name="keyChain"></param> /// <param name="dag"></param> internal ChunkedStream(IBlockApi blockService, IKeyApi keyChain, IDagNode dag) { BlockService = blockService; KeyChain = keyChain; var links = dag.Links.ToArray(); var dm = Serializer.Deserialize <DataMessage>(dag.DataStream); if (dm.FileSize != null) { Length = (long)dm.FileSize; } ulong position = 0; for (var i = 0; i < dm.BlockSizes.Length; ++i) { blocks.Add(new BlockInfo { Id = links[i].Id, Position = (long)position }); position += dm.BlockSizes[i]; } }
public void RemoveUnorderedInput(IDagNode node) { _dagCalculateComponent.RemoveUnorderedInput(node); }
public void AddUnorderedInput(IDagNode node) { _dagCalculateComponent.AddUnorderedInput(node); }
public void SetInput(int index, IDagNode node) { _dagCalculateComponent.SetInput(index, node); }
public async Task <IDagNode> PutAsync(IDagNode node, CancellationToken cancel = default) { node.Id = await _blockApi.PutAsync(node.ToArray(), cancel : cancel).ConfigureAwait(false); return(node); }
public static void UnLinkUnordered(IDagNode input, IDagNodeCalculateBase output) { output.RemoveUnorderedInput(input); input.RemoveOutput(output); output.SetDirty(); }
public static void UnLink(int index, IDagNode input, IDagNodeCalculateBase output) { output.SetInput(index, null); input.RemoveOutput(output); output.SetDirty(); }
public static void Link(int index, IDagNode input, IDagNodeCalculateBase output) { output.SetInput(index, input); input.AddOutput(output); output.SetDirty(); }
public void RemoveUnorderedInput(IDagNode node) { _unorderedInputArray.Remove(node); }
public void AddUnorderedInput(IDagNode node) { _unorderedInputArray.Add(node); }