コード例 #1
0
ファイル: Program.cs プロジェクト: Blecki/RMUDReboot
 private static void WriteCharacter(char C)
 {
     if (OutputState == OutputStates.ReadingColor)
     {
         if (C == ';')
         {
             var color = ConsoleColor.White;
             if (Enum.TryParse(ColorName, out color))
             {
                 Console.ForegroundColor = color;
             }
             OutputState = OutputStates.Normal;
         }
         else
         {
             ColorName += C;
         }
     }
     else if (C == '$')
     {
         OutputState = OutputStates.ReadingColor;
         ColorName   = "";
     }
     else
     {
         Console.Write(C);
     }
 }
コード例 #2
0
ファイル: UnspentTx.cs プロジェクト: ArsenShnurkov/BitSharp
 public UnspentTx(UInt256 txHash, int blockIndex, int txIndex, int length, OutputState state)
 {
     TxHash = txHash;
     BlockIndex = blockIndex;
     TxIndex = txIndex;
     OutputStates = new OutputStates(length, state);
     IsFullySpent = state == OutputState.Spent;
 }
コード例 #3
0
ファイル: UnspentTx.cs プロジェクト: ArsenShnurkov/BitSharp
 public UnspentTx(UInt256 txHash, int blockIndex, int txIndex, OutputStates outputStates)
 {
     TxHash = txHash;
     BlockIndex = blockIndex;
     TxIndex = txIndex;
     OutputStates = outputStates;
     IsFullySpent = OutputStates.All(x => x == OutputState.Spent);
 }
コード例 #4
0
 public static byte[] EncodeOutputStates(OutputStates outputStates)
 {
     using (var stream = new MemoryStream())
     {
         EncodeOutputStates(stream, outputStates);
         return(stream.ToArray());
     }
 }
コード例 #5
0
 public static void EncodeOutputStates(Stream stream, OutputStates outputStates)
 {
     using (var writer = new BinaryWriter(stream, Encoding.ASCII, leaveOpen: true))
     {
         writer.WriteVarBytes(outputStates.ToByteArray());
         writer.WriteInt32(outputStates.Length);
     }
 }
コード例 #6
0
ファイル: UnspentTx.cs プロジェクト: cole2295/BitSharp
 public UnspentTx(UInt256 txHash, int blockIndex, int txIndex, uint txVersion, bool isCoinbase, OutputStates outputStates)
 {
     TxHash = txHash;
     BlockIndex = blockIndex;
     TxIndex = txIndex;
     TxVersion = txVersion;
     IsCoinbase = isCoinbase;
     OutputStates = outputStates;
     IsFullySpent = OutputStates.All(x => x == OutputState.Spent);
 }
コード例 #7
0
ファイル: DataEncoder.cs プロジェクト: yonglehou/BitSharp
        public static byte[] EncodeOutputStates(OutputStates outputStates)
        {
            var outputStateBytes = outputStates.ToByteArray();
            var buffer           = new byte[4 + outputStateBytes.Length];

            Buffer.BlockCopy(BitConverter.GetBytes(outputStates.Length), 0, buffer, 0, 4);
            Buffer.BlockCopy(outputStateBytes, 0, buffer, 4, outputStateBytes.Length);

            return(buffer);
        }
コード例 #8
0
ファイル: DataDecoder.cs プロジェクト: yonglehou/BitSharp
        public static UnspentTx DecodeUnspentTx(byte[] buffer, ref int offset)
        {
            var txHash     = DecodeUInt256(buffer, ref offset);
            var blockIndex = DecodeInt32(buffer, ref offset);
            var index      = DecodeInt32(buffer, ref offset);
            var txVersion  = DecodeUInt32(buffer, ref offset);
            var isCoinbase = DecodeBool(buffer, ref offset);

            var outputStateBits   = buffer.ReadVarBytes(ref offset);
            var outputStateLength = DecodeInt32(buffer, ref offset);
            var outputStates      = new OutputStates(outputStateBits, outputStateLength);

            return(new UnspentTx(txHash, blockIndex, index, txVersion, isCoinbase, outputStates));
        }
コード例 #9
0
ファイル: DataEncoder.cs プロジェクト: cole2295/BitSharp
        public static byte[] EncodeOutputStates(OutputStates outputStates)
        {
            var outputStateBytes = outputStates.ToByteArray();
            var buffer = new byte[4 + outputStateBytes.Length];

            Buffer.BlockCopy(BitConverter.GetBytes(outputStates.Length), 0, buffer, 0, 4);
            Buffer.BlockCopy(outputStateBytes, 0, buffer, 4, outputStateBytes.Length);

            return buffer;
        }
コード例 #10
0
ファイル: DataDecoder.cs プロジェクト: cole2295/BitSharp
        public static UnspentTx DecodeUnspentTx(byte[] buffer, ref int offset)
        {
            var txHash = DecodeUInt256(buffer, ref offset);
            var blockIndex = DecodeInt32(buffer, ref offset);
            var index = DecodeInt32(buffer, ref offset);
            var txVersion = DecodeUInt32(buffer, ref offset);
            var isCoinbase = DecodeBool(buffer, ref offset);

            var outputStateBits = buffer.ReadVarBytes(ref offset);
            var outputStateLength = DecodeInt32(buffer, ref offset);
            var outputStates = new OutputStates(outputStateBits, outputStateLength);

            return new UnspentTx(txHash, blockIndex, index, txVersion, isCoinbase, outputStates);
        }