Exemple #1
0
        public override string ToString()
        {
            List <object> parts = new List <object>();

            if (MapObject != null)
            {
                parts.Add(MapObject);
            }
            if (ObjAddress != null)
            {
                parts.Add(HexUtilities.FormatValue(ObjAddress));
            }
            if (Tri != null)
            {
                parts.Add(HexUtilities.FormatValue(Tri.Address));
            }
            if (IsTriUnit)
            {
                parts.Add("Unit");
            }
            if (Index.HasValue)
            {
                parts.Add(Index);
            }
            if (Index2.HasValue)
            {
                parts.Add(Index2);
            }
            parts.Add(string.Format("({0}, {1}, {2})", HandleRounding(X), HandleRounding(Y), HandleRounding(Z)));
            if (Info != null)
            {
                parts.Add(Info);
            }
            return(string.Join(" ", parts));
        }
Exemple #2
0
        /// <inheritdoc />
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var contentHashListWithDeterminism = (ContentHashListWithDeterminism)value;
            var contentHashList = contentHashListWithDeterminism.ContentHashList;
            var determinism     = contentHashListWithDeterminism.Determinism;

            writer.WriteStartObject();
            if (contentHashList.HasPayload)
            {
                writer.WritePropertyName(PayloadFieldName);
                serializer.Serialize(
                    writer,
                    HexUtilities.BytesToHex(contentHashList.Payload.ToList()));
            }

            writer.WritePropertyName(DeterminismFieldName);
            serializer.Serialize(writer, determinism.Guid.ToString());

            writer.WritePropertyName(ExpirationUtcFieldName);
            serializer.Serialize(writer, determinism.ExpirationUtc.ToBinary());

            writer.WritePropertyName(HashesFieldName);
            var hashes = contentHashList.Hashes.Select(hash => hash.SerializeReverse()).ToList();

            serializer.Serialize(writer, hashes, typeof(List <string>));

            writer.WriteEndObject();
        }
Exemple #3
0
    private void placeAround(int idx, UnitInfo[] roster, int player, bool human)
    {
        Debug.Log("Roster Size: " + roster.Length);

        Queue <HexCell> availableCells = new Queue <HexCell> ();

        availableCells.Enqueue(cells[idx]);
        int total = roster.Length - 1;

        while (total >= 0)
        {
            HexCell        cell = availableCells.Dequeue();
            HexDirection[] dirs = cell.dirs;
            HexUtilities.ShuffleArray(dirs);
            foreach (HexDirection dir in dirs)
            {
                HexCell n = cell.GetNeighbor(dir);
                if (n)
                {
                    availableCells.Enqueue(n);
                }
            }
            if (cell.GetInfo().playerNo == -1)
            {
                placePlayer(cell, player, false, roster[total].type, human);
                total--;
            }
        }
    }
Exemple #4
0
        /// <inheritdoc />
        public override object ReadJson(
            JsonReader reader,
            Type objectType,
            object existingValue,
            JsonSerializer serializer)
        {
            JObject jsonObject = JObject.Load(reader);

            byte[] output;
            JToken outputToken;

            if (jsonObject.TryGetValue(WeakFingerprintFieldName, StringComparison.Ordinal, out outputToken))
            {
                output = HexUtilities.HexToBytes(outputToken.Value <string>());
            }
            else
            {
                throw new ArgumentException("Invalid json for a Strong Fingerprint: no WeakFingerprint found.");
            }

            JToken   selectorToken;
            Selector selector;

            if (jsonObject.TryGetValue(SelectorFieldName, out selectorToken))
            {
                selector = (Selector)_selectorConverter.GetSelectorFromJReader(selectorToken.CreateReader());
            }
            else
            {
                throw new ArgumentException("Invalid JSON for Strong Fingerprint. no selector found");
            }

            return(new StrongFingerprint(new Fingerprint(output), selector));
        }
Exemple #5
0
        private (string host, ContentHash contentHash) ExtractHostHashFromAbsolutePath(AbsolutePath sourcePath)
        {
            // TODO: Keep the segments in the AbsolutePath object?
            // TODO: Indexable structure?
            var segments = sourcePath.GetSegments();

            Contract.Assert(segments.Count >= 4);

            var host        = sourcePath.IsLocal ? "localhost" : segments.First();
            var hashLiteral = segments.Last();

            if (hashLiteral.EndsWith(GrpcDistributedPathTransformer.BlobFileExtension, StringComparison.OrdinalIgnoreCase))
            {
                hashLiteral = hashLiteral.Substring(0, hashLiteral.Length - GrpcDistributedPathTransformer.BlobFileExtension.Length);
            }
            var hashTypeLiteral = segments.ElementAt(segments.Count - 1 - 2);

            if (!Enum.TryParse(hashTypeLiteral, ignoreCase: true, out HashType hashType))
            {
                throw new InvalidOperationException($"{hashTypeLiteral} is not a valid member of {nameof(HashType)}");
            }

            var contentHash = new ContentHash(hashType, HexUtilities.HexToBytes(hashLiteral));

            return(host, contentHash);
        }
        public void HexToBytesBadChars()
        {
            const string goodChars = "0123456789ABCDEFabcdef";

            var badCharactersMistakenlyAllowed = new List <char>();

            for (char c = '!'; c <= '~'; c++)
            {
                if (goodChars.IndexOf(c) == -1)
                {
                    try
                    {
                        HexUtilities.HexToBytes(new string(new[] { c, c }));

                        // Should not get here.
                        badCharactersMistakenlyAllowed.Add(c);
                    }
                    catch (ArgumentException)
                    {
                    }
                }
            }

            Assert.Equal(0, badCharactersMistakenlyAllowed.Count);
        }
        public string GetDescriptiveSlotLabelFromAddress(uint objAddress, bool concise)
        {
            string noObjectString      = concise ? ".." : "(no object)";
            string unusedObjectString  = concise ? "UU" : "(unused object)";
            string unknownObjectString = concise ? ".." : "(unknown object)";
            string slotLabelPrefix     = concise ? "" : "Slot ";
            string processGroupPrefix  = concise ? "PG" : "PG ";

            if (objAddress == 0)
            {
                return(noObjectString);
            }
            if (objAddress == ObjectSlotsConfig.UnusedSlotAddress)
            {
                return(unusedObjectString);
            }

            byte?processGroup = ObjectUtilities.GetProcessGroup(objAddress);

            if (processGroup.HasValue)
            {
                return(processGroupPrefix + HexUtilities.FormatValue(processGroup.Value, 1, false));
            }

            string slotLabel = GetSlotLabelFromAddress(objAddress);

            if (slotLabel == null)
            {
                return(unknownObjectString);
            }
            return(slotLabelPrefix + slotLabel);
        }
Exemple #8
0
    private static List <HexCell> iterateBackFromPoint(HexCell end, Dictionary <HexCell, int> tblStore)
    {
        List <HexCell> path    = new List <HexCell>();
        HexCell        current = end;
        int            turn    = tblStore [end] - 1;

        path.Add(end);

        while (turn > 0)
        {
            HexDirection[] dirs = current.dirs;
            HexUtilities.ShuffleArray(dirs);
            foreach (HexDirection dir in dirs)
            {
                if (current.GetNeighbor(dir) && tblStore.ContainsKey(current.GetNeighbor(dir)) && tblStore [current.GetNeighbor(dir)] == turn)
                {
                    path.Add(current.GetNeighbor(dir));
                    current = current.GetNeighbor(dir);
                    turn--;
                    break;
                }
            }
        }
        return(path);
    }
Exemple #9
0
        internal void Delete
        (
            [Required, Description(GrpcPortDescription)] int grpcPort,
            [Required, Description(HashTypeDescription)] string hashType,
            [Required, Description("Content hash value of referenced content to place")] string hash
        )
        {
            Initialize();

            var context          = new Interfaces.Tracing.Context(_logger);
            var operationContext = new OperationContext(context);

            try
            {
                Validate();

                var ht          = GetHashTypeByNameOrDefault(hashType);
                var contentHash = new ContentHash(ht, HexUtilities.HexToBytes(hash));

                GrpcContentClient client = new GrpcContentClient(
                    new ServiceClientContentSessionTracer(nameof(Delete)),
                    _fileSystem,
                    new ServiceClientRpcConfiguration(grpcPort),
                    _scenario);

                var deleteResult = client.DeleteContentAsync(operationContext, contentHash, deleteLocalOnly: false).GetAwaiter().GetResult();
                _tracer.Always(context, deleteResult.ToString());
            }
            catch (Exception e)
            {
                _tracer.Error(context, e, $"Unhandled exception in {nameof(Application)}.{nameof(Delete)}");
            }
        }
Exemple #10
0
        private TreeNode GetTreeNodeForType(uint partitionAddress, int z, int x, int type)
        {
            int  typeSize = 2 * 4;
            int  xSize    = 3 * typeSize;
            int  zSize    = 16 * xSize;
            uint address  = (uint)(partitionAddress + z * zSize + x * xSize + type * typeSize);

            address = Config.Stream.GetUInt(address);

            List <TreeNode> nodes = new List <TreeNode>();

            while (address != 0)
            {
                uint     triAddress       = Config.Stream.GetUInt(address + 4);
                short    y1               = TriangleOffsetsConfig.GetY1(triAddress);
                string   triAddressString = HexUtilities.FormatValue(triAddress) + " (y1 = " + y1 + ")";
                TreeNode subNode          = new TreeNode(triAddressString);
                subNode.Tag = triAddress;
                nodes.Add(subNode);
                address = Config.Stream.GetUInt(address);
            }

            string   name = (type == 0 ? "Floors" : type == 1 ? "Ceilings" : "Walls") + " [" + nodes.Count + "]";
            TreeNode node = new TreeNode(name);

            node.Tag = nodes.Count;
            node.Nodes.AddRange(nodes.ToArray());
            return(node);
        }
        public void EncodeBase58Test()
        {
            var data     = HexUtilities.HexStringToBytes("80010966776006953D5567439E5E39F86A0D273BEF");
            var expected = "8sXcP7DRdQ3HArnsEDVjKLXStwZF4";
            var actual   = Base58Utilities.EncodeBase58(data);

            Assert.AreEqual(expected, actual);
        }
Exemple #12
0
        public void AddressFromBytesTest(string addressHex, string addressWif)
        {
            // With prefix
            Assert.Equal(addressWif, new Address(HexUtilities.HexToBytes(addressHex)).ToString());

            // Without prefix
            Assert.Equal(addressWif, new Address(HexUtilities.HexToBytes(addressHex.Substring(2))).ToString());
        }
    public Hex(int col, int row)
    {
        Vector3 cubePos = HexUtilities.OffsetToCube(col, row);

        x = (int)cubePos.x;
        y = (int)cubePos.y;
        z = (int)cubePos.z;
    }
Exemple #14
0
        public void RefreshAddressBox()
        {
            List <string> triangleAddressStrings = TriangleAddresses.ConvertAll(
                triAddress => HexUtilities.FormatValue(triAddress, 8));
            string newText = string.Join(",", triangleAddressStrings);

            _addressBox.SubmitTextLoosely(newText);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BlobIdentifier"/> class.
        /// </summary>
        /// <remarks>
        /// The value is expected to contain both the hash and the algorithm id.
        /// </remarks>
        /// <param name="valueIncludingAlgorithm">Must be the value corresponding to the ValueString of the id to be created.</param>
        private BlobIdentifier(string valueIncludingAlgorithm)
        {
            if (string.IsNullOrWhiteSpace(valueIncludingAlgorithm))
            {
                throw new ArgumentNullException(nameof(valueIncludingAlgorithm), "BlobIdentifier cannot be instantiated, hash value is invalid.");
            }

            if (!HexUtilities.TryToByteArray(valueIncludingAlgorithm, out byte[]? parsedValue))
Exemple #16
0
        public SoundManager(TabPage tabPage)
        {
            SplitContainer splitContainerSound = tabPage.Controls["splitContainerSound"] as SplitContainer;

            SplitContainer splitContainerSoundMusic = splitContainerSound.Panel1.Controls["splitContainerSoundMusic"] as SplitContainer;
            ListBox        listBoxSoundMusic        = splitContainerSoundMusic.Panel1.Controls["listBoxSoundMusic"] as ListBox;
            TextBox        textBoxSoundMusic        = splitContainerSoundMusic.Panel2.Controls["textBoxSoundMusic"] as TextBox;
            Button         buttonSoundPlayMusic     = splitContainerSoundMusic.Panel2.Controls["buttonSoundPlayMusic"] as Button;

            SplitContainer splitContainerSoundSoundEffect = splitContainerSound.Panel2.Controls["splitContainerSoundSoundEffect"] as SplitContainer;
            ListBox        listBoxSoundSoundEffect        = splitContainerSoundSoundEffect.Panel1.Controls["listBoxSoundSoundEffect"] as ListBox;
            TextBox        textBoxSoundSoundEffect        = splitContainerSoundSoundEffect.Panel2.Controls["textBoxSoundSoundEffect"] as TextBox;
            Button         buttonSoundPlaySoundEffect     = splitContainerSoundSoundEffect.Panel2.Controls["buttonSoundPlaySoundEffect"] as Button;

            TableConfig.MusicData.GetMusicEntryList().ForEach(musicEntry => listBoxSoundMusic.Items.Add(musicEntry));
            listBoxSoundMusic.Click += (sender, e) =>
            {
                MusicEntry musicEntry = listBoxSoundMusic.SelectedItem as MusicEntry;
                textBoxSoundMusic.Text = musicEntry.Index.ToString();
            };
            buttonSoundPlayMusic.Click += (sender, e) =>
            {
                int?musicIndexNullable = ParsingUtilities.ParseIntNullable(textBoxSoundMusic.Text);
                if (musicIndexNullable == null)
                {
                    return;
                }
                int musicIndex = musicIndexNullable.Value;
                if (musicIndex < 0 || musicIndex > 34)
                {
                    return;
                }
                uint setMusic = RomVersionConfig.SwitchMap(0x80320544, 0x8031F690);
                InGameFunctionCall.WriteInGameFunctionCall(setMusic, 0, (uint)musicIndex, 0);
            };

            foreach (uint soundEffect in _soundEffects)
            {
                string soundEffectString = HexUtilities.FormatValue(soundEffect, 4);
                listBoxSoundSoundEffect.Items.Add(soundEffectString);
            }
            listBoxSoundSoundEffect.Click += (sender, e) =>
            {
                textBoxSoundSoundEffect.Text = listBoxSoundSoundEffect.SelectedItem.ToString() + "FF81";
            };
            buttonSoundPlaySoundEffect.Click += (sender, e) =>
            {
                uint setSound            = RomVersionConfig.SwitchMap(0x8031EB00, 0x8031DC78);
                uint soundArg            = RomVersionConfig.SwitchMap(0x803331F0, 0x803320E0);
                uint?soundEffectNullable = ParsingUtilities.ParseHexNullable(textBoxSoundSoundEffect.Text);
                if (!soundEffectNullable.HasValue)
                {
                    return;
                }
                uint soundEffect = soundEffectNullable.Value;
                InGameFunctionCall.WriteInGameFunctionCall(setSound, soundEffect, soundArg);
            };
        }
Exemple #17
0
 public override List <XAttribute> GetXAttributes()
 {
     return(new List <XAttribute>()
     {
         new XAttribute("positionAngle", _posAngle),
         new XAttribute("yawOffset", HexUtilities.FormatValue(_yawOffset)),
         new XAttribute("numBytes", _numBytes),
     });
 }
Exemple #18
0
        public override List <XAttribute> GetXAttributes()
        {
            List <string> hexList = _triList.ConvertAll(tri => HexUtilities.FormatValue(tri.Address));

            return(new List <XAttribute>()
            {
                new XAttribute("triangles", string.Join(",", hexList)),
            });
        }
        public void ParseWifStringTest()
        {
            // Compressed: "1E99423A4ED27608A15A2616A2B0E9E52CED330AC530EDCC32C8FFC6A526AEDD";
            var expectedBytes = HexUtilities.HexStringToBytes("801E99423A4ED27608A15A2616A2B0E9E52CED330AC530EDCC32C8FFC6A526AEDD01");
            var input         = "KxFC1jmwwCoACiCAWZ3eXa96mBM6tb3TYzGmf6YwgdGWZgawvrtJ";
            var prvKey        = PrivateKey.CreateFromWifString(input);
            var wifBytes      = prvKey.GetWifBytes();

            Assert.IsTrue(ByteArrayUtilities.CompareByteArrays(expectedBytes, wifBytes));
            var wifString = prvKey.GetWifString();

            Assert.AreEqual(input, wifString);
            Assert.IsTrue(prvKey.WifCompressed);
            Assert.IsFalse(prvKey.TestNet);

            // Compressed (TestNet): "1cca23de92fd1862fb5b76e5f4f50eb082165e5191e116c18ed1a6b24be6a53f";
            expectedBytes = HexUtilities.HexStringToBytes("ef1cca23de92fd1862fb5b76e5f4f50eb082165e5191e116c18ed1a6b24be6a53f01");
            input         = "cNYfWuhDpbNM1JWc3c6JTrtrFVxU4AGhUKgw5f93NP2QaBqmxKkg";
            prvKey        = PrivateKey.CreateFromWifString(input);
            wifBytes      = prvKey.GetWifBytes();
            Assert.IsTrue(ByteArrayUtilities.CompareByteArrays(expectedBytes, wifBytes));
            wifString = prvKey.GetWifString();
            Assert.AreEqual(input, wifString);
            Assert.IsTrue(prvKey.WifCompressed);
            Assert.IsTrue(prvKey.TestNet);

            // Uncompressed: "1E99423A4ED27608A15A2616A2B0E9E52CED330AC530EDCC32C8FFC6A526AEDD";
            expectedBytes = HexUtilities.HexStringToBytes("801E99423A4ED27608A15A2616A2B0E9E52CED330AC530EDCC32C8FFC6A526AEDD");
            input         = "5J3mBbAH58CpQ3Y5RNJpUKPE62SQ5tfcvU2JpbnkeyhfsYB1Jcn";
            prvKey        = PrivateKey.CreateFromWifString(input);
            wifBytes      = prvKey.GetWifBytes();
            Assert.IsTrue(ByteArrayUtilities.CompareByteArrays(expectedBytes, wifBytes));
            wifString = prvKey.GetWifString();
            Assert.AreEqual(input, wifString);
            Assert.IsFalse(prvKey.WifCompressed);
            Assert.IsFalse(prvKey.TestNet);

            // Uncompressed: "0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D";
            input         = "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ";
            expectedBytes = HexUtilities.HexStringToBytes("800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D");
            prvKey        = PrivateKey.CreateFromWifString(input);
            wifBytes      = prvKey.GetWifBytes();
            Assert.IsTrue(ByteArrayUtilities.CompareByteArrays(expectedBytes, wifBytes));
            wifString = prvKey.GetWifString();
            Assert.AreEqual(input, wifString);
            Assert.IsFalse(prvKey.WifCompressed);
            Assert.IsFalse(prvKey.TestNet);

            // Uncompressed (TestNet): "93XfLeifX7Jx7n7ELGMAf1SUR6f9kgQs8Xke8WStMwUtrDucMzn";
            input  = "93XfLeifX7Jx7n7ELGMAf1SUR6f9kgQs8Xke8WStMwUtrDucMzn";
            prvKey = PrivateKey.CreateFromWifString(input);
            Assert.AreEqual((BigInteger.Pow(2, 256) - BigInteger.Pow(2, 201)), prvKey.Value);
            wifString = prvKey.GetWifString();
            Assert.AreEqual(input, wifString);
            Assert.IsFalse(prvKey.WifCompressed);
            Assert.IsTrue(prvKey.TestNet);
        }
Exemple #20
0
        public void DoubleSha256Test()
        {
            var data          = Encoding.ASCII.GetBytes("hello");
            var dblSha256Hash = HashUtilities.DoubleSha256(data);

            var actual   = HexUtilities.BytesToHexString(dblSha256Hash);
            var expected = "9595c9df90075148eb06860365df33584b75bff782a510c6cd4883a419833d50";

            Assert.AreEqual(expected, actual);
        }
 protected override object HandleHexDisplaying(object value)
 {
     if (!_displayAsHex)
     {
         return(value);
     }
     return(SavedSettingsConfig.DisplayAsHexUsesMemory
         ? HexUtilities.FormatMemory(value, GetHexDigitCount(), true)
         : HexUtilities.FormatValue(value, GetHexDigitCount(), true));
 }
Exemple #22
0
        public void Hash160Test()
        {
            var data    = Encoding.ASCII.GetBytes("hello");
            var hash160 = HashUtilities.Hash160(data);

            var actual   = HexUtilities.BytesToHexString(hash160);
            var expected = "b6a9c8c230722b7c748331a8b450f05566dc7d0f";

            Assert.AreEqual(expected, actual);
        }
Exemple #23
0
        public void RipeMd160Test()
        {
            var data          = Encoding.ASCII.GetBytes("hello");
            var ripeMd160Hash = HashUtilities.RipeMd160(data);

            var actual   = HexUtilities.BytesToHexString(ripeMd160Hash);
            var expected = "108f07b8382412612c048d07d13f814118445acd";

            Assert.AreEqual(expected, actual);
        }
Exemple #24
0
        public static DedupIdentifier Create(string valueIncludingAlgorithm)
        {
            if (string.IsNullOrWhiteSpace(valueIncludingAlgorithm))
            {
                throw new ArgumentNullException(nameof(valueIncludingAlgorithm));
            }

            byte[] value = HexUtilities.HexToBytes(valueIncludingAlgorithm);
            return(DedupIdentifier.Create(new HashAndAlgorithm(value)));
        }
Exemple #25
0
        public void Sha256Test()
        {
            var data       = Encoding.ASCII.GetBytes("hello");
            var sha256Hash = HashUtilities.Sha256(data);

            var actual   = HexUtilities.BytesToHexString(sha256Hash);
            var expected = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824";

            Assert.AreEqual(expected, actual);
        }
        public void EncodeBase58CheckVersion5Test()
        {
            // Version 5 (0x05) Prefixes (Pay-to-Script-Hash Addresses)

            var data     = HexUtilities.HexStringToBytes("0574E9D4CDE54B8A6DECDD997541E44508FF8BA5E8");
            var expected = "3CMCRgEm8HVz3DrWaCCid3vAANE42jcEv9";
            var actual   = Base58Utilities.EncodeBase58Check(data);

            Assert.AreEqual(expected, actual);
        }
        public override void ApplySettings(MapObjectSettings settings)
        {
            base.ApplySettings(settings);

            if (settings.ChangeTriangle)
            {
                _customWallTri = settings.NewTriangle;
                string suffix = _customWallTri.HasValue ? string.Format(" ({0})", HexUtilities.FormatValue(_customWallTri)) : "";
                _itemSetCustomWallTriangle.Text = SET_CUSTOM_WALL_TRIANGLE_TEXT + suffix;
            }
        }
Exemple #28
0
        }         // End of AddNode().

        // Add a new node to the Assembly at local position.
        private void AddRandomNode()
        {
            int  randomStartNode = Random.random.Next(0, nodesList.Count);
            Node rootNode        = null;
            bool foundLegalPos   = false;

            // If we don't have any nodes... we'll just make one at 0, 0, 0.
            Triplet newNodePos = Triplet.zero;

            if (nodesList.Count == 0)
            {
                foundLegalPos = true;
            }
            else
            {
                for (int i = 0; i < nodesList.Count; i++)
                {
                    int wrappedNodeIndex = (randomStartNode + i) % nodesList.Count;
                    rootNode = nodesList[wrappedNodeIndex];
                    if (rootNode.NeighborsList.Count > 1)
                    {
                        continue;
                    }

                    int randomStartDir = Random.random.Next(12);
                    for (int j = 0; j < nodesList.Count; j++)
                    {
                        int wrappedDirIndex = (randomStartDir + j) % 12;
                        int curDir          = wrappedDirIndex % 12;
                        newNodePos = rootNode.LocalHexPos + HexUtilities.Adjacent(curDir);
                        if (!nodesDict.ContainsKey(newNodePos))
                        {
                            foundLegalPos = true;
                            break;
                        }
                    }

                    if (foundLegalPos)
                    {
                        break;
                    }
                }
            }

            if (foundLegalPos)
            {
                Node newNode = AddNode(newNodePos);
                if (rootNode != null)
                {
                    rootNode.AssignNeighbor(newNode);
                    newNode.AssignNeighbor(rootNode);
                }
            }
        }         // End of AddNode().
Exemple #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BlobIdentifier"/> class.
        /// </summary>
        /// <remarks>
        /// The value is expected to contain both the hash and the algorithm id.
        /// </remarks>
        /// <param name="valueIncludingAlgorithm">Must be the value corresponding to the ValueString of the id to be created.</param>
        private BlobIdentifier(string valueIncludingAlgorithm)
        {
            if (string.IsNullOrWhiteSpace(valueIncludingAlgorithm))
            {
                throw new ArgumentNullException(nameof(valueIncludingAlgorithm), "Invalid hash value");
            }

            // Ignore the result of this call as ValidateInternal will check for null.
            _identifierValue = HexUtilities.HexToBytes(valueIncludingAlgorithm);
            Validate();
        }
 public override Address ReadJson(JsonReader reader, Type objectType, Address existingValue, bool hasExistingValue, JsonSerializer serializer)
 {
     if (reader.TokenType == JsonToken.String)
     {
         return(new Address(HexUtilities.HexToBytes((string)reader.Value)));
     }
     else
     {
         throw new JsonSerializationException("Invalid token type");
     }
 }