当前位置: 首页>>代码示例>>C#>>正文


C# BinaryWriter.WriteBytes方法代码示例

本文整理汇总了C#中System.IO.BinaryWriter.WriteBytes方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteBytes方法的具体用法?C# BinaryWriter.WriteBytes怎么用?C# BinaryWriter.WriteBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.BinaryWriter的用法示例。


在下文中一共展示了BinaryWriter.WriteBytes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EncodeMessage

 public static void EncodeMessage(BinaryWriter writer, Message message)
 {
     writer.WriteUInt32(message.Magic);
     writer.WriteFixedString(12, message.Command);
     writer.WriteUInt32(message.PayloadSize);
     writer.WriteUInt32(message.PayloadChecksum);
     writer.WriteBytes(message.PayloadSize.ToIntChecked(), message.Payload.ToArray());
 }
开发者ID:cole2295,项目名称:BitSharp,代码行数:8,代码来源:NodeEncoder.cs

示例2: EncodeNetworkAddress

 public static void EncodeNetworkAddress(BinaryWriter writer, NetworkAddress networkAddress)
 {
     writer.WriteUInt64(networkAddress.Services);
     writer.WriteBytes(16, networkAddress.IPv6Address.ToArray());
     writer.WriteUInt16BE(networkAddress.Port);
 }
开发者ID:cole2295,项目名称:BitSharp,代码行数:6,代码来源:NodeEncoder.cs

示例3: EncodeTotalWork

        public static void EncodeTotalWork(BinaryWriter writer, BigInteger totalWork)
        {
            if (totalWork < 0)
                throw new ArgumentOutOfRangeException();

            var totalWorkBytesLittleEndian = totalWork.ToByteArray();
            if (totalWorkBytesLittleEndian.Length > 64)
                throw new ArgumentOutOfRangeException();

            var totalWorkBytesLittleEndian64 = new byte[64];
            Buffer.BlockCopy(totalWorkBytesLittleEndian, 0, totalWorkBytesLittleEndian64, 0, totalWorkBytesLittleEndian.Length);

            var totalWorkBytesBigEndian = totalWorkBytesLittleEndian64.Reverse().ToArray();

            writer.WriteBytes(totalWorkBytesBigEndian);
            Debug.Assert(new BigInteger(totalWorkBytesLittleEndian64) == totalWork);
        }
开发者ID:cole2295,项目名称:BitSharp,代码行数:17,代码来源:DataEncoder.cs

示例4: PrepareSaveData

        private int PrepareSaveData(byte[] destBuf)
        {
            using (var stream = new MemoryStream(destBuf))
            {
                using (var bw = new BinaryWriter(stream))
                {
                    bw.BaseStream.Seek(4, SeekOrigin.Begin);
                    bw.WriteUInt32(SaveFileRevision);
                    bw.WriteUInt32((uint) SystemVars.Instance.GameVersion.Version.Minor);

                    bw.WriteUInt16(_skySound.SaveSounds[0]);
                    bw.WriteUInt16(_skySound.SaveSounds[1]);

                    bw.WriteUInt32(_skyMusic.CurrentMusic);
                    bw.WriteUInt32(_savedCharSet);
                    bw.WriteUInt32(_savedMouse);
                    bw.WriteUInt32(SystemVars.Instance.CurrentPalette);
                    for (var cnt = 0; cnt < Logic.NumSkyScriptVars; cnt++)
                        bw.WriteUInt32(_skyLogic.ScriptVariables[cnt]);
                    var loadedFilesList = _skyDisk.LoadedFilesList;

                    for (var cnt = 0; cnt < 60; cnt++)
                        bw.WriteUInt32(loadedFilesList[cnt]);

                    for (var cnt = 0; cnt < _skyCompact.SaveIds.Length; cnt++)
                    {
                        var rawCpt = _skyCompact.FetchCptRaw(_skyCompact.SaveIds[cnt]);
                        bw.WriteBytes(rawCpt, rawCpt.Length);
                    }

                    var length = bw.BaseStream.Position;
                    bw.BaseStream.Seek(0, SeekOrigin.Begin);
                    bw.WriteUInt32((uint) length);
                    return (int) length;
                }
            }
        }
开发者ID:scemino,项目名称:nscumm,代码行数:37,代码来源:Control.cs

示例5: EncodeBlockTxNode

 public static void EncodeBlockTxNode(BinaryWriter writer, BlockTxNode blockTx)
 {
     writer.WriteInt32(blockTx.Index);
     writer.WriteInt32(blockTx.Depth);
     writer.WriteUInt256(blockTx.Hash);
     writer.WriteBool(blockTx.Pruned);
     if (!blockTx.Pruned)
         writer.WriteBytes(blockTx.TxBytes.ToArray());
 }
开发者ID:cole2295,项目名称:BitSharp,代码行数:9,代码来源:DataEncoder.cs

示例6: EncodeBlock

 public static void EncodeBlock(BinaryWriter writer, Block block)
 {
     EncodeBlockHeader(writer, block.Header);
     writer.WriteList(block.BlockTxes, tx => writer.WriteBytes(tx.TxBytes.ToArray()));
 }
开发者ID:cole2295,项目名称:BitSharp,代码行数:5,代码来源:DataEncoder.cs

示例7: TxSignature

        public byte[] TxSignature(byte[] scriptPubKey, Transaction tx, int inputIndex, byte hashType)
        {
            ///TODO
            Debug.Assert(inputIndex < tx.Inputs.Length);

            // Blank out other inputs' signatures
            var empty = ImmutableArray.Create<byte>();
            var newInputs = ImmutableArray.CreateBuilder<TxInput>(tx.Inputs.Length);
            for (var i = 0; i < tx.Inputs.Length; i++)
            {
                var oldInput = tx.Inputs[i];
                var newInput = oldInput.With(scriptSignature: i == inputIndex ? scriptPubKey.ToImmutableArray() : empty);
                newInputs.Add(newInput);
            }

            //// Blank out some of the outputs
            //if ((hashType & 0x1F) == (int)ScriptHashType.SIGHASH_NONE)
            //{
            //    //TODO
            //    Debug.Assert(false);

            //    // Wildcard payee

            //    // Let the others update at will
            //}
            //else if ((hashType & 0x1F) == (int)ScriptHashType.SIGHASH_SINGLE)
            //{
            //    //TODO
            //    Debug.Assert(false);

            //    // Only lock-in the txout payee at same index as txin

            //    // Let the others update at will
            //}

            //// Blank out other inputs completely, not recommended for open transactions
            //if ((hashType & 0x80) == (int)ScriptHashType.SIGHASH_ANYONECANPAY)
            //{
            //    //TODO
            //    Debug.Assert(false);
            //}

            // create simplified transaction
            var newTx = tx.With(Inputs: newInputs.ToImmutable());

            // return wire-encoded simplified transaction with the 4-byte hashType tacked onto the end
            using (var stream = new MemoryStream())
            using (var writer = new BinaryWriter(stream))
            {
                writer.WriteBytes(DataEncoder.EncodeTransaction(newTx));
                writer.WriteUInt32(hashType);

                return stream.ToArray();
            }
        }
开发者ID:ArsenShnurkov,项目名称:BitSharp,代码行数:55,代码来源:ScriptEngine.cs

示例8: EncodeNetworkAddress

 public static void EncodeNetworkAddress(Stream stream, NetworkAddress networkAddress)
 {
     using (var writer = new BinaryWriter(stream, Encoding.ASCII, leaveOpen: true))
     {
         writer.Write8Bytes(networkAddress.Services);
         writer.WriteBytes(16, networkAddress.IPv6Address.ToArray());
         writer.Write2BytesBE(networkAddress.Port);
     }
 }
开发者ID:knocte,项目名称:BitSharp,代码行数:9,代码来源:NetworkEncoder.cs

示例9: EncodeMessage

 public static void EncodeMessage(Stream stream, Message message)
 {
     using (var writer = new BinaryWriter(stream, Encoding.ASCII, leaveOpen: true))
     {
         writer.Write4Bytes(message.Magic);
         writer.WriteFixedString(12, message.Command);
         writer.Write4Bytes(message.PayloadSize);
         writer.Write4Bytes(message.PayloadChecksum);
         writer.WriteBytes(message.PayloadSize.ToIntChecked(), message.Payload.ToArray());
     }
 }
开发者ID:knocte,项目名称:BitSharp,代码行数:11,代码来源:NetworkEncoder.cs


注:本文中的System.IO.BinaryWriter.WriteBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。