コード例 #1
0
        internal static BlockEvent DeserializeBlockEvent(JsonElement element)
        {
            long            sequence        = default;
            BlockIdentifier blockIdentifier = default;
            BlockEventType  type            = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sequence"))
                {
                    sequence = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("block_identifier"))
                {
                    blockIdentifier = BlockIdentifier.DeserializeBlockIdentifier(property.Value);
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new BlockEventType(property.Value.GetString());
                    continue;
                }
            }
            return(new BlockEvent(sequence, blockIdentifier, type));
        }
コード例 #2
0
        internal BlockEvent(long sequence, BlockIdentifier blockIdentifier, BlockEventType type)
        {
            if (blockIdentifier == null)
            {
                throw new ArgumentNullException(nameof(blockIdentifier));
            }

            Sequence        = sequence;
            BlockIdentifier = blockIdentifier;
            Type            = type;
        }