System.IO.BinaryWriter.Write(string)

Here are the examples of the csharp api System.IO.BinaryWriter.Write(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2682 Examples 7

19 View Source File : CelesteNetBinaryWriter.cs
License : MIT License
Project Creator : 0x0ade

public virtual void Write(Color value) {
            Write(value.R);
            Write(value.G);
            Write(value.B);
            Write(value.A);
        }

19 View Source File : CelesteNetBinaryWriter.cs
License : MIT License
Project Creator : 0x0ade

public virtual void Write(Vector2 value) {
            Write(value.X);
            Write(value.Y);
        }

19 View Source File : CelesteNetBinaryWriter.cs
License : MIT License
Project Creator : 0x0ade

public virtual void WriteNoA(Color value) {
            Write(value.R);
            Write(value.G);
            Write(value.B);
        }

19 View Source File : CelesteNetBinaryWriter.cs
License : MIT License
Project Creator : 0x0ade

public void WriteRef<T>(T? data) where T : DataType<T>
            => Write((data ?? throw new Exception($"Expected {Data.DataTypeToID[typeof(T)]} to write, got null")).Get<MetaRef>(Data) ?? uint.MaxValue);

19 View Source File : CelesteNetBinaryWriter.cs
License : MIT License
Project Creator : 0x0ade

public void WriteOptRef<T>(T? data) where T : DataType<T>
            => Write(data?.GetOpt<MetaRef>(Data) ?? uint.MaxValue);

19 View Source File : CelesteNetUtils.BinaryRWCompat.cs
License : MIT License
Project Creator : 0x0ade

[Obsolete("Use CelesteNetBinaryWriter instead.")]
        public static void Write(this BinaryWriter writer, Vector2 value) {
            writer.Write(value.X);
            writer.Write(value.Y);
        }

19 View Source File : CelesteNetUtils.BinaryRWCompat.cs
License : MIT License
Project Creator : 0x0ade

[Obsolete("Use CelesteNetBinaryWriter instead.")]
        public static void Write(this BinaryWriter writer, Color value) {
            writer.Write(value.R);
            writer.Write(value.G);
            writer.Write(value.B);
            writer.Write(value.A);
        }

19 View Source File : CelesteNetUtils.BinaryRWCompat.cs
License : MIT License
Project Creator : 0x0ade

[Obsolete("Use CelesteNetBinaryWriter instead.")]
        public static void WriteNoA(this BinaryWriter writer, Color value) {
            writer.Write(value.R);
            writer.Write(value.G);
            writer.Write(value.B);
        }

19 View Source File : DataContext.cs
License : MIT License
Project Creator : 0x0ade

[Obsolete("Use CelesteNetBinaryWriter instead.")]
        public void WriteRef<T>(BinaryWriter writer, T? data) where T : DataType<T>
            => writer.Write((data ?? throw new Exception($"Expected {DataTypeToID[typeof(T)]} to write, got null")).Get<MetaRef>(this) ?? uint.MaxValue);

19 View Source File : DataContext.cs
License : MIT License
Project Creator : 0x0ade

[Obsolete("Use CelesteNetBinaryWriter instead.")]
        public void WriteOptRef<T>(BinaryWriter writer, T? data) where T : DataType<T>
            => writer.Write(data?.GetOpt<MetaRef>(this) ?? uint.MaxValue);

19 View Source File : ExifWriter.cs
License : MIT License
Project Creator : 0xC0000054

public byte[] CreateExifBlob()
        {
            IFDInfo ifdInfo = BuildIFDEntries();
            Dictionary<MetadataSection, IFDEntryInfo> ifdEntries = ifdInfo.IFDEntries;

            byte[] exifBytes = new byte[checked((int)ifdInfo.EXIFDataLength)];

            using (MemoryStream stream = new MemoryStream(exifBytes))
            using (BinaryWriter writer = new BinaryWriter(stream))
            {
                IFDEntryInfo imageInfo = ifdEntries[MetadataSection.Image];
                IFDEntryInfo exifInfo = ifdEntries[MetadataSection.Exif];

                writer.Write(TiffConstants.LittleEndianByteOrderMarker);
                writer.Write(TiffConstants.Signature);
                writer.Write((uint)imageInfo.StartOffset);

                WriteDirectory(writer, metadata[MetadataSection.Image], imageInfo.IFDEntries, imageInfo.StartOffset);
                WriteDirectory(writer, metadata[MetadataSection.Exif], exifInfo.IFDEntries, exifInfo.StartOffset);

                if (ifdEntries.TryGetValue(MetadataSection.Interop, out IFDEntryInfo interopInfo))
                {
                    WriteDirectory(writer, metadata[MetadataSection.Interop], interopInfo.IFDEntries, interopInfo.StartOffset);
                }

                if (ifdEntries.TryGetValue(MetadataSection.Gps, out IFDEntryInfo gpsInfo))
                {
                    WriteDirectory(writer, metadata[MetadataSection.Gps], gpsInfo.IFDEntries, gpsInfo.StartOffset);
                }
            }

            return exifBytes;
        }

19 View Source File : ExifWriter.cs
License : MIT License
Project Creator : 0xC0000054

public byte[] CreateExifBlob()
        {
            IFDInfo ifdInfo = BuildIFDEntries();
            Dictionary<MetadataSection, IFDEntryInfo> ifdEntries = ifdInfo.IFDEntries;

            byte[] exifBytes = new byte[checked((int)ifdInfo.EXIFDataLength)];

            using (MemoryStream stream = new MemoryStream(exifBytes))
            using (BinaryWriter writer = new BinaryWriter(stream))
            {
                IFDEntryInfo imageInfo = ifdEntries[MetadataSection.Image];
                IFDEntryInfo exifInfo = ifdEntries[MetadataSection.Exif];

                writer.Write(TiffConstants.LittleEndianByteOrderMarker);
                writer.Write(TiffConstants.Signature);
                writer.Write((uint)imageInfo.StartOffset);

                WriteDirectory(writer, this.metadata[MetadataSection.Image], imageInfo.IFDEntries, imageInfo.StartOffset);
                WriteDirectory(writer, this.metadata[MetadataSection.Exif], exifInfo.IFDEntries, exifInfo.StartOffset);

                if (ifdEntries.TryGetValue(MetadataSection.Interop, out IFDEntryInfo interopInfo))
                {
                    WriteDirectory(writer, this.metadata[MetadataSection.Interop], interopInfo.IFDEntries, interopInfo.StartOffset);
                }

                if (ifdEntries.TryGetValue(MetadataSection.Gps, out IFDEntryInfo gpsInfo))
                {
                    WriteDirectory(writer, this.metadata[MetadataSection.Gps], gpsInfo.IFDEntries, gpsInfo.StartOffset);
                }
            }

            return exifBytes;
        }

19 View Source File : ExifWriter.cs
License : MIT License
Project Creator : 0xC0000054

private void WriteDirectory(BinaryWriter writer, Dictionary<ushort, MetadataEntry> tags, List<IFDEntry> entries, long ifdOffset)
        {
            writer.BaseStream.Position = ifdOffset;

            long nextIFDPointerOffset = ifdOffset + sizeof(ushort) + ((long)entries.Count * IFDEntry.SizeOf);

            writer.Write((ushort)entries.Count);

            foreach (IFDEntry entry in entries.OrderBy(e => e.Tag))
            {
                entry.Write(writer);

                if (!TagDataTypeUtil.ValueFitsInOffsetField(entry.Type, entry.Count))
                {
                    long oldPosition = writer.BaseStream.Position;

                    writer.BaseStream.Position = entry.Offset;

                    writer.Write(tags[entry.Tag].GetDataReadOnly());

                    writer.BaseStream.Position = oldPosition;
                }
            }

            writer.BaseStream.Position = nextIFDPointerOffset;
            // There is only one IFD in this directory.
            writer.Write(0);
        }

19 View Source File : ExifWriter.cs
License : MIT License
Project Creator : 0xC0000054

private void WriteDirectory(BinaryWriter writer, Dictionary<ushort, MetadataEntry> tags,  List<IFDEntry> entries, long ifdOffset)
        {
            writer.BaseStream.Position = ifdOffset;

            long nextIFDPointerOffset = ifdOffset + sizeof(ushort) + ((long)entries.Count * IFDEntry.SizeOf);

            writer.Write((ushort)entries.Count);

            foreach (IFDEntry entry in entries.OrderBy(e => e.Tag))
            {
                entry.Write(writer);

                if (!TagDataTypeUtil.ValueFitsInOffsetField(entry.Type, entry.Count))
                {
                    long oldPosition = writer.BaseStream.Position;

                    writer.BaseStream.Position = entry.Offset;

                    writer.Write(tags[entry.Tag].GetDataReadOnly());

                    writer.BaseStream.Position = oldPosition;
                }
            }

            writer.BaseStream.Position = nextIFDPointerOffset;
            // There is only one IFD in this directory.
            writer.Write(0);
        }

19 View Source File : WaveFormatExtraData.cs
License : MIT License
Project Creator : 3wz

public override void Serialize(BinaryWriter writer)
        {
            base.Serialize(writer);
            if (extraSize > 0)
            {
                writer.Write(extraData, 0, extraSize);
            }
        }

19 View Source File : TLV_0105.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            var data = new BinaryWriter(new MemoryStream());
            if (WSubVer == 0x0001)
            {
                data.BeWrite(WSubVer); //wSubVer
                data.Write(user.TXProtocol.XxooB);
                data.Write((byte) 2);
                data.BeUshortWrite(0x0014);
                data.BeWrite(0x01010010);
                data.Write(Util.RandomKey());
                data.BeUshortWrite(0x0014);
                data.BeWrite(0x01020010);
                data.Write(Util.RandomKey());
            }
            else
            {
                throw new Exception($"{Name} 无法识别的版本号 {WSubVer}");
            }

            FillHead(Command);
            FillBody(data.BaseStream.ToBytesArray(), data.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : TLV_0112.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            var data = new BinaryWriter(new MemoryStream());
            data.Write(user.TXProtocol.BufSigClientAddr);
            FillHead(Command);
            FillBody(data.BaseStream.ToBytesArray(), data.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : TLV_0114.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            var data = new BinaryWriter(new MemoryStream());
            if (WSubVer == 0x0102)
            {
                data.BeWrite(WSubVer); //wDHVer
                data.BeWrite((ushort) user.TXProtocol.BufDhPublicKey.Length); //bufDHPublicKey长度
                data.Write(user.TXProtocol.BufDhPublicKey);
            }
            else
            {
                throw new Exception($"{Name} 无法识别的版本号 {WSubVer}");
            }

            FillHead(Command);
            FillBody(data.BaseStream.ToBytesArray(), data.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : TLV_0309.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            var data = new BinaryWriter(new MemoryStream());
            if (WSubVer == 0x0001)
            {
                data.BeWrite(WSubVer); //wSubVer
                data.Write(Util.IPStringToByteArray(user.TXProtocol.DwServerIP)); //LastServerIP - 服务器最后的登录IP,可以为0
                data.Write((byte) user.TXProtocol.RedirectIP.Count); //cRedirectCount - 重定向的次数(IP的数量)
                foreach (var ip in user.TXProtocol.RedirectIP)
                {
                    data.Write(ip);
                }

                data.Write(user.TXProtocol.CPingType); //cPingType 
            }
            else
            {
                throw new Exception($"{Name} 无法识别的版本号 {WSubVer}");
            }

            FillHead(Command);
            FillBody(data.BaseStream.ToBytesArray(), data.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : TLV_030F.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            var data = new BinaryWriter(new MemoryStream());
            data.BeWrite((ushort) Encoding.UTF8.GetBytes(user.TXProtocol.BufComputerName).Length);
            data.Write(Encoding.UTF8.GetBytes(user.TXProtocol.BufComputerName));
            FillHead(Command);
            FillBody(data.BaseStream.ToBytesArray(), data.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : Send_0x0352.cs
License : MIT License
Project Creator : 499116344

protected override void PutBody()
        {
            var pic = new Bitmap(FileName);
            var width = pic.Size.Width; // 图片的宽度
            var height = pic.Size.Height; // 图片的高度
            var picBytes = ImageHelper.ImageToBytes(pic);
            var md5 = QQTea.MD5(picBytes);

            var data = new BinaryWriter(new MemoryStream());
            data.Write(new byte[]
            {
                0x01, 0x08, 0x01, 0x12
            });
            data.Write((byte) 0x5A);
            data.Write((byte) 0x08);
            data.Write(Util.HexStringToByteArray(Util.PB_toLength(User.QQ)));
            data.Write((byte) 0x10);
            data.Write(Util.HexStringToByteArray(Util.PB_toLength(ToQQ)));
            data.BeWrite((ushort) 0x1800);
            data.Write((byte) 0x22);
            data.Write((byte) 0x10);
            data.Write(md5);
            data.Write((byte) 0x28);
            data.Write(Util.HexStringToByteArray(Util.PB_toLength(picBytes.Length)));
            data.Write((byte) 0x32);
            data.Write((byte) 0x1A);
            data.Write(new byte[]
            {
                0x57, 0x00, 0x53, 0x00, 0x4E, 0x00, 0x53, 0x00, 0x4C, 0x00, 0x54, 0x00,
                0x31, 0x00, 0x36, 0x00, 0x47, 0x00, 0x45, 0x00, 0x4F, 0x00, 0x5B, 0x00,
                0x5F, 0x00
            });
            data.BeWrite((ushort) 0x3801);
            data.BeWrite((ushort) 0x4801);
            data.Write((byte) 0x70);
            data.Write(Util.HexStringToByteArray(Util.PB_toLength(width)));
            data.Write((byte) 0x78);
            data.Write(Util.HexStringToByteArray(Util.PB_toLength(height)));

            BodyWriter.Write(new byte[]
            {
                0x00, 0x00, 0x00, 0x07
            });
            //数据长度
            BodyWriter.BeWrite(data.BaseStream.Length);
            BodyWriter.Write(new byte[]
            {
                0x08, 0x01, 0x12, 0x03, 0x98, 0x01
            });
            //数据
            BodyWriter.Write(data.BaseStream.ToBytesArray());
        }

19 View Source File : Send_0x03F7.cs
License : MIT License
Project Creator : 499116344

protected override void PutBody()
        {
            var pbGroupId = Util.HexStringToByteArray(Util.PB_toLength(_groupId));
            var pbMessageId =
                Util.HexStringToByteArray(
                    Util.PB_toLength(Convert.ToInt64(Util.ToHex(_messageId).Replace(" ", ""), 16)));
            var pbMessageIndex =
                Util.HexStringToByteArray(
                    Util.PB_toLength(Convert.ToInt64(Util.ToHex(_messageIndex).Replace(" ", ""), 16)));
            BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 });
            var data = new BinaryWriter(new MemoryStream());
            data.Write(new byte[] { 0x08, 0x01, 0x10, 0x00, 0x18 });
            data.Write(pbGroupId);
            data.Write(new byte[] { 0x22, 0x09, 0x08 });
            data.Write(pbMessageIndex); //消息索引
            data.Write((byte) 0x10);
            data.Write(pbMessageId); //消息Id
            var data_2A = new BinaryWriter(new MemoryStream());
            data_2A.Write(new byte[] { 0x08, 0x00 });
            var data12 = new BinaryWriter(new MemoryStream());
            data12.Write((byte) 0x08);
            data12.Write(pbMessageIndex); //消息索引
            data12.Write((byte) 0x10);
            data12.Write(new byte[] { 0x00, 0x18, 0x01, 0x20, 0x00 });
            data_2A.Write((byte) 0x12);
            data_2A.Write((byte) data12.BaseStream.Length);
            data_2A.Write(data12.BaseStream.ToBytesArray());
            data.Write((byte) 0x2a);
            data.Write((byte) data_2A.BaseStream.Length);
            data.Write(data_2A.BaseStream.ToBytesArray());
            //数据长度
            BodyWriter.BeWrite(data.BaseStream.Length);
            BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00 });
            //数据
            BodyWriter.Write(data.BaseStream.ToBytesArray());
        }

19 View Source File : Send_0x03FC.cs
License : MIT License
Project Creator : 499116344

protected override void PutBody()
        {
            BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 });
            var data = new BinaryWriter(new MemoryStream());
            var data_0A = new BinaryWriter(new MemoryStream());
            data_0A.Write((byte) 0x08);
            data_0A.Write(Util.HexStringToByteArray(Util.PB_toLength(User.QQ)));
            data_0A.Write((byte) 0x10);
            data_0A.Write(Util.HexStringToByteArray(Util.PB_toLength(_recvQQ)));
            data_0A.Write((byte) 0x18);
            data_0A.Write(Util.HexStringToByteArray(Util.PB_toLength(_msgSequence))); //消息包序
            data_0A.Write((byte) 0x28);
            data_0A.Write(
                Util.HexStringToByteArray(
                    Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageTime).Replace(" ", ""), 16))));
            data_0A.Write(new byte[] { 0x30 });
            data_0A.Write(
                Util.HexStringToByteArray(
                    Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageId).Replace(" ", ""), 16)))); //消息Id
            data_0A.Write(new byte[] { 0x38, 0x01, 0x40, 0x00, 0x48, 0x00 });
            data.Write((byte) 0x0A);
            data.Write((byte) data_0A.BaseStream.Length); //length
            data.Write(data_0A.BaseStream.ToBytesArray());
            data.Write(new byte[] { 0x10, 0x01, 0x18, 0x01, 0x20, 0x00, 0x2a, 0x04, 0x08, 0x00, 0x10, 0x00 });
            //数据长度
            BodyWriter.BeWrite(data.BaseStream.Length);
            BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00 });
            //数据
            BodyWriter.Write(data.BaseStream.ToBytesArray());
        }

19 View Source File : SendPacket.cs
License : MIT License
Project Creator : 499116344

protected virtual void PutHeader()
        {
            Writer.Write(QQGlobal.QQHeaderBasicFamily);
            Writer.Write(User.TXProtocol.CMainVer);
            Writer.Write(User.TXProtocol.CSubVer);
            Writer.BeWrite((ushort) Command);
            Writer.BeWrite(Sequence);
            Writer.BeWrite(User.QQ);
        }

19 View Source File : SendPacket.cs
License : MIT License
Project Creator : 499116344

protected void SendPACKET_FIX()
        {
            Writer.Write(User.TXProtocol.XxooA);
            Writer.Write(User.TXProtocol.DwClientType);
            Writer.Write(User.TXProtocol.DwPubNo);
            Writer.Write(User.TXProtocol.XxooD);
        }

19 View Source File : SendPacket.cs
License : MIT License
Project Creator : 499116344

protected virtual void PutTail()
        {
            Writer.Write(QQGlobal.QQHeader03Family);
        }

19 View Source File : QdData.cs
License : MIT License
Project Creator : 499116344

public static byte[] GetQdData(QQUser user)
        {
            try
            {
                var data = new BinaryWriter(new MemoryStream());
                data.Write(user.TXProtocol.DwServerIP);

                var qddata = new BinaryWriter(new MemoryStream());
                qddata.Write(user.TXProtocol.DwQdVerion);
                qddata.Write(user.TXProtocol.DwPubNo);
                qddata.BeWrite(user.QQ);
                qddata.BeWrite((ushort) data.BaseStream.Length);

                data = new BinaryWriter(new MemoryStream());
                data.Write(user.TXProtocol.QdPreFix);
                data.BeWrite(user.TXProtocol.CQdProtocolVer);
                data.BeWrite(user.TXProtocol.DwQdVerion);
                data.Write((byte) 0);
                data.BeWrite(user.TXProtocol.WQdCsCmdNo);
                data.Write(user.TXProtocol.CQdCcSubNo);
                data.Write(new byte[] { 0x0E, 0x88 }); //xrand(0xFFFF) + 1
                data.BeWrite(0); //四个0
                data.Write(user.TXProtocol.BufComputerIdEx);
                data.Write(user.TXProtocol.COsType);
                data.Write(user.TXProtocol.BIsWow64);
                data.Write(user.TXProtocol.DwPubNo);
                data.BeWrite((ushort) user.TXProtocol.DwClientVer);
                data.BeWrite(user.TXProtocol.DwDrvVersionInfo / 0x10000);
                data.BeWrite(user.TXProtocol.DwDrvVersionInfo % 0x10000);
                data.Write(user.TXProtocol.BufVersionTsSafeEditDat);
                data.Write(user.TXProtocol.BufVersionQScanEngineDll);
                data.Write((byte) 0);

                data.Write(new TeaCrypter().Encrypt(qddata.BaseStream.ToBytesArray(), user.TXProtocol.BufQdKey));

                data.Write(user.TXProtocol.QdSufFix);

                var size = data.BaseStream.Length + 3;
                qddata = new BinaryWriter(new MemoryStream());
                qddata.Write(user.TXProtocol.QdPreFix);
                qddata.Write(size);
                qddata.Write(data.BaseStream.Length);

                var result = data.BaseStream.ToBytesArray();
                user.TXProtocol.QdData = result;
                return result;
            }
            catch
            {
                return new byte[] { };
            }
        }

19 View Source File : EncodingUtil.cs
License : MIT License
Project Creator : 404Lcc

public static byte[] SocketModelEncode(SocketModel model)
        {
            byte[] bytes;
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write(model.type);
                    writer.Write(model.area);
                    writer.Write(model.command);
                    if (model.message != null)
                    {
                        writer.Write(SerializationEncode(model.message));
                    }
                    bytes = stream.ToArray();
                }
            }
            return bytes;

        }

19 View Source File : Util.cs
License : MIT License
Project Creator : 499116344

public static List<byte[]> WriteSnippet(TextSnippet snippet, int length)
        {
            // TODO: 富文本支持
            var ret = new List<byte[]>();
            var bw = new BinaryWriter(new MemoryStream());
            switch (snippet.Type)
            {
                case MessageType.Normal:
                {
                    if (length + 6 >= 699) // 数字应该稍大点,但是我不清楚具体是多少
                    {
                        length = 0;
                        ret.Add(new byte[0]);
                    }

                    bw.BaseStream.Position = 6;
                    foreach (var chr in snippet.Content)
                    {
                        var bytes = Encoding.UTF8.GetBytes(chr.ToString());
                        // 705 = 699 + 6个byte: (byte + short + byte + short)
                        if (length + bw.BaseStream.Length + bytes.Length > 705)
                        {
                            var pos = bw.BaseStream.Position;
                            bw.BaseStream.Position = 0;
                            bw.Write(new byte[]
                            {
                                0x01
                            });
                            bw.BeWrite((ushort) (pos - 3)); // 本来是+3和0的,但是提前预留了6个byte给它们,所以变成了-3和-6。下同理。
                            bw.Write(new byte[]
                            {
                                0x01
                            });
                            bw.BeWrite((ushort) (pos - 6));
                            bw.BaseStream.Position = pos;
                            ret.Add(bw.BaseStream.ToBytesArray());
                            bw = new BinaryWriter(new MemoryStream());
                            bw.BaseStream.Position = 6;
                            length = 0;
                        }

                        bw.Write(bytes);
                    }

                    // 在最后一段的开头补充结构 
                    {
                        var pos = bw.BaseStream.Position;
                        bw.BaseStream.Position = 0;
                        bw.Write(new byte[]
                        {
                            0x01
                        });
                        bw.BeWrite((ushort) (pos - 3));
                        bw.Write(new byte[]
                        {
                            0x01
                        });
                        bw.BeWrite((ushort) (pos - 6));
                        bw.BaseStream.Position = pos;
                    }
                    break;
                }
                case MessageType.At:
                    break;
                case MessageType.Emoji:
                {
                    if (length + 12 > 699)
                    {
                        ret.Add(new byte[0]);
                    }

                    var faceIndex = Convert.ToByte(snippet.Content);
                    if (faceIndex > 199)
                    {
                        faceIndex = 0;
                    }

                    bw.Write(new byte[]
                    {
                        0x02,
                        0x00,
                        0x14,
                        0x01,
                        0x00,
                        0x01
                    });
                    bw.Write(faceIndex);
                    bw.Write(new byte[]
                    {
                        0xFF,
                        0x00,
                        0x02,
                        0x14
                    });
                    bw.Write((byte) (faceIndex + 65));
                    bw.Write(new byte[]
                    {
                        0x0B,
                        0x00,
                        0x08,
                        0x00,
                        0x01,
                        0x00,
                        0x04,
                        0x52,
                        0xCC,
                        0x85,
                        0x50
                    });
                    break;
                }
                case MessageType.Picture:
                    break;
                case MessageType.Xml:
                    break;
                case MessageType.Json:
                    break;
                case MessageType.Shake:
                    break;
                case MessageType.Audio:
                    break;
                case MessageType.Video:
                    break;
                case MessageType.ExitGroup:
                    break;
                case MessageType.GetGroupImformation:
                    break;
                case MessageType.AddGroup:
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            if (bw.BaseStream.Position != 0)
            {
                ret.Add(bw.BaseStream.ToBytesArray());
            }

            return ret;
        }

19 View Source File : TLV_0004.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            if (user.QQ != 0)
            {
                return null;
            }

            var data = new BinaryWriter(new MemoryStream());
            if (WSubVer == 0x0000)
            {
                data.BeWrite(WSubVer); //wSubVer 
                var bufAccount = Util.HexStringToByteArray(Util.NumToHexString(user.QQ));
                data.BeWrite((ushort) bufAccount.Length); //账号长度
                data.Write(bufAccount); //账号
            }
            else
            {
                throw new Exception($"{Name} 无法识别的版本号 {WSubVer}");
            }

            FillHead(Command);
            FillBody(data.BaseStream.ToBytesArray(), data.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : TLV_0006.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            if (WSubVer == 0x0002)
            {
                if (user.TXProtocol.BufTgtgt == null)
                {
                    var data = new BinaryWriter(new MemoryStream());
                    data.BeWrite(new Random(Guid.NewGuid().GetHashCode()).Next()); //随机4字节??
                    data.BeWrite(WSubVer); //wSubVer
                    data.BeWrite(user.QQ); //QQ号码
                    data.BeWrite(user.TXProtocol.DwSsoVersion);
                    data.BeWrite(user.TXProtocol.DwServiceId);
                    data.BeWrite(user.TXProtocol.DwClientVer);
                    data.BeWrite((ushort) 0);
                    data.Write(user.TXProtocol.BRememberPwdLogin);
                    data.Write(user.MD51); //密码的一次MD5值,服务器用该MD5值验证用户密码是否正确
                    data.BeWrite(user.TXProtocol.DwServerTime); //登录时间
                    data.Write(new byte[13]); //固定13字节
                    data.Write(Util.IPStringToByteArray(user.TXProtocol.DwClientIP)); //IP地址
                    data.BeWrite(user.TXProtocol.DwIsp); //dwISP
                    data.BeWrite(user.TXProtocol.DwIdc); //dwIDC
                    data.WriteKey(user.TXProtocol.BufComputerIdEx); //机器码
                    data.Write(user.TXProtocol.BufTgtgtKey); //00DD临时密钥(通过验证时客户端用该密钥解密服务端发送回来的数据)

                    user.TXProtocol.BufTgtgt =
                        QQTea.Encrypt(data.BaseStream.ToBytesArray(), user.Md52());
                }
            }
            else
            {
                throw new Exception($"{Name} 无法识别的版本号 {WSubVer}");
            }

            var tlv = new BinaryWriter(new MemoryStream());
            tlv.Write(user.TXProtocol.BufTgtgt);
            FillHead(Command);
            FillBody(tlv.BaseStream.ToBytesArray(), tlv.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : TLV_0007.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            var bufTgt = user.TXProtocol.BufTgt;
            var buf = new BinaryWriter(new MemoryStream());
            buf.Write(bufTgt);
            FillHead(Command);
            FillBody(buf.BaseStream.ToBytesArray(), buf.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : TLV_000C.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            var data = new BinaryWriter(new MemoryStream());
            if (WSubVer == 0x0002)
            {
                data.BeWrite(WSubVer); //wSubVer
                data.BeWrite((ushort) 0);
                data.BeWrite(user.TXProtocol.DwIdc);
                data.BeWrite(user.TXProtocol.DwIsp);
                data.Write(Util.IPStringToByteArray(user.TXProtocol.DwServerIP));
                data.BeWrite(user.TXProtocol.WServerPort);
                data.BeWrite(0);
            }
            else
            {
                throw new Exception($"{Name} 无法识别的版本号 {WSubVer}");
            }

            FillHead(Command);
            FillBody(data.BaseStream.ToBytesArray(), data.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : TLV_001F.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            if (user.TXProtocol.BufDeviceId == null)
            {
                return new byte[] { };
            }

            var data = new BinaryWriter(new MemoryStream());
            if (WSubVer == 0x0001)
            {
                data.BeWrite(WSubVer); //wSubVer
                data.Write(user.TXProtocol.BufDeviceId);
            }
            else
            {
                throw new Exception($"{Name} 无法识别的版本号 {WSubVer}");
            }

            FillHead(Command);
            FillBody(data.BaseStream.ToBytesArray(), data.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : TLV_002D.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            var data = new BinaryWriter(new MemoryStream());
            if (WSubVer == 0x0001)
            {
                data.BeWrite(WSubVer); //wSubVer 
                data.Write(Util.IPStringToByteArray(GetLocalIP())); //本机内网IP地址
            }
            else
            {
                throw new Exception($"{Name} 无法识别的版本号 {WSubVer}");
            }

            FillHead(Command);
            FillBody(data.BaseStream.ToBytesArray(), data.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : TLV_010B.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            var data = new BinaryWriter(new MemoryStream());
            if (WSubVer == 0x0002)
            {
                data.BeWrite(WSubVer); //wSubVer
                var newbyte = user.TXProtocol.BufTgt;
                var flag = EncodeLoginFlag(newbyte, QQGlobal.QqexeMD5);
                data.Write(user.MD51);
                data.Write(flag);
                data.Write((byte) 0x10);
                data.BeWrite(0);
                data.BeWrite(2);
                var qddata = QdData.GetQdData(user);
                data.WriteKey(qddata);
                data.BeWrite(0);
            }
            else
            {
                throw new Exception($"{Name} 无法识别的版本号 {WSubVer}");
            }

            FillHead(Command);
            FillBody(data.BaseStream.ToBytesArray(), data.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : TLV_050C.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            var buf = new BinaryWriter(new MemoryStream());
            var dataTime = DateTime.Now;
            buf.BeWrite(0);
            buf.BeWrite(user.QQ);
            buf.Write(new byte[] { 0x76, 0x71, 0x01, 0x9d });
            buf.BeWrite(Util.GetTimeMillis(dataTime));
            buf.BeWrite(user.TXProtocol.DwServiceId);
            buf.Write(new byte[]
                { 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x00, 0x04, 0x5f, 0x80, 0x33, 0x01, 0x01 });
            buf.BeWrite(user.TXProtocol.DwClientVer);
            buf.Write(new byte[]
                { 0x66, 0x35, 0x4d, 0xf1, 0xab, 0xdc, 0x98, 0xf0, 0x70, 0x69, 0xfc, 0x2a, 0x2b, 0x86, 0x06, 0x1b });
            buf.BeWrite(user.TXProtocol.SubVer);

            var data = new BinaryWriter(new MemoryStream());
            data.BeWrite(0);
            data.BeWrite(user.QQ);
            data.Write(new byte[] { 0x76, 0x71, 0x01, 0x9d });
            data.BeWrite(Util.GetTimeMillis(dataTime));
            data.Write(user.TXProtocol.DwPubNo);

            buf.Write((byte) data.BaseStream.Length * 3);
            buf.Write(data.BaseStream.ToBytesArray());
            buf.Write(data.BaseStream.ToBytesArray());
            buf.Write(data.BaseStream.ToBytesArray());


            FillHead(Command);
            FillBody(buf.BaseStream.ToBytesArray(), buf.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : Send_0x0319.cs
License : MIT License
Project Creator : 499116344

protected override void PutBody()
        {
            BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 });
            var data = new BinaryWriter(new MemoryStream());
            data.Write(new byte[] { 0x0A, 0x0C, 0x08 });
            data.Write(Util.HexStringToByteArray(Util.PB_toLength(_recvQQ)));
            data.Write((byte) 0x10);
            data.Write(
                Util.HexStringToByteArray(
                    Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageTime).Replace(" ", ""), 16))));
            data.Write(new byte[] { 0x20, 0x00 });
            //数据长度
            BodyWriter.BeWrite(data.BaseStream.Length);
            BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00 });
            //数据
            BodyWriter.Write(data.BaseStream.ToBytesArray());
        }

19 View Source File : Send_0x0360.cs
License : MIT License
Project Creator : 499116344

protected override void PutBody()
        {
            BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 });
            var data = new BinaryWriter(new MemoryStream());
            data.Write(new byte[] { 0x03, 0x08, 0x03, 0x22, 0x46, 0x08 });
            data.Write(Util.HexStringToByteArray(Util.PB_toLength(_recvGroupQQ)));
            data.Write((byte) 0x10);
            data.Write(
                Util.HexStringToByteArray(
                    Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageTime).Replace(" ", ""), 16))));
            data.Write(new byte[] { 0x20, 0x00 });
            //数据长度
            BodyWriter.BeWrite(data.BaseStream.Length);
            BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00 });
            //数据
            BodyWriter.Write(data.BaseStream.ToBytesArray());
        }

19 View Source File : Send_0x0391.cs
License : MIT License
Project Creator : 499116344

protected override void PutBody()
        {
            BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x0D });
            var data = new BinaryWriter(new MemoryStream());
            data.Write(new byte[] { 0x0A, 0x12, 0x08 });
            data.Write(Util.HexStringToByteArray(Util.PB_toLength(GroupQQ)));
            data.Write(new byte[] { 0x12, 0x0a, 0x38, 0x00, 0x40, 0x00, 0x4a, 0x04, 0x08, 0x00, 0x10, 0x00 });
            //数据长度
            BodyWriter.BeWrite(data.BaseStream.Length);
            BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x09 });

            var data12 = new BinaryWriter(new MemoryStream());
            data12.Write(
                Util.HexStringToByteArray(
                    Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageIndex).Replace(" ", ""), 16))));
            data12.Write(new byte[] { 0x88, 0x01, 0x04, 0x98, 0x01, 0x00 });

            BodyWriter.Write((byte) data12.BaseStream.Length);
            BodyWriter.Write(data12.BaseStream.ToBytesArray());

            //数据
            BodyWriter.Write(data.BaseStream.ToBytesArray());
        }

19 View Source File : SendPacket.cs
License : MIT License
Project Creator : 499116344

[Obsolete("请使用BinaryWriter.Write(Richtext)方法。")]
        public static byte[] SendXml(byte[] compressMsg)
        {
            var bw = new BinaryWriter(new MemoryStream());
            bw.Write(Util.RandomKey(4));
            bw.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 });
            bw.Write(new byte[] { 0x00, 0x0C });
            bw.Write(new byte[] { 0xE5, 0xBE, 0xAE, 0xE8, 0xBD, 0xAF, 0xE9, 0x9B, 0x85, 0xE9, 0xBB, 0x91 });
            bw.Write(new byte[] { 0x00, 0x00, 0x14 });
            bw.BeWrite((ushort) (compressMsg.Length + 11));
            bw.Write((byte) 0x01);
            bw.BeWrite((ushort) (compressMsg.Length + 1));
            bw.Write((byte) 0x01);
            bw.Write(compressMsg);
            bw.Write(new byte[] { 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x4D });
            return bw.BaseStream.ToBytesArray();
        }

19 View Source File : SimpleJSON.cs
License : MIT License
Project Creator : 734843327

public override void Serialize (System.IO.BinaryWriter aWriter)
		{
			aWriter.Write((byte)JSONBinaryTag.Clreplaced);
			aWriter.Write(m_Dict.Count);
			foreach(string K in m_Dict.Keys)
			{
				aWriter.Write(K);
				m_Dict[K].Serialize(aWriter);
			}
		}

19 View Source File : SimpleJSON.cs
License : MIT License
Project Creator : 734843327

public override void Serialize (System.IO.BinaryWriter aWriter)
		{
			var tmp = new JSONData("");
			
			tmp.AsInt = AsInt;
			if (tmp.m_Data == this.m_Data)
			{
				aWriter.Write((byte)JSONBinaryTag.IntValue);
				aWriter.Write(AsInt);
				return;
			}
			tmp.AsFloat = AsFloat;
			if (tmp.m_Data == this.m_Data)
			{
				aWriter.Write((byte)JSONBinaryTag.FloatValue);
				aWriter.Write(AsFloat);
				return;
			}
			tmp.AsDouble = AsDouble;
			if (tmp.m_Data == this.m_Data)
			{
				aWriter.Write((byte)JSONBinaryTag.DoubleValue);
				aWriter.Write(AsDouble);
				return;
			}

			tmp.AsBool = AsBool;
			if (tmp.m_Data == this.m_Data)
			{
				aWriter.Write((byte)JSONBinaryTag.BoolValue);
				aWriter.Write(AsBool);
				return;
			}
			aWriter.Write((byte)JSONBinaryTag.Value);
			aWriter.Write(m_Data);
		}

19 View Source File : IPCSupport.cs
License : GNU General Public License v3.0
Project Creator : 9E4ECDDE

public void Send(Message messageType, string boneName, object data)
            {
                if (!IsConnected) throw new InvalidOperationException("Tried to send a message but the pipe is disconnected.");
                switch (messageType)
                {
                    case Message.SetBoneData:
                        {
                            if (!IsServer) throw new InvalidOperationException("GetBoneData can only be called from the server.");
                            pipeWriter.Write((int)Message.SetBoneData);
                            pipeWriter.Write((byte[])data);
                            break;
                        }
                    case Message.SetBoneDamping:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneDamping can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneDamping);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write((float)data);
                            break;
                        }
                    case Message.SetBoneElasticity:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneElasticity can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneElasticity);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write((float)data);
                            break;
                        }
                    case Message.SetBoneStiffness:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneStiffness can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneStiffness);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write((float)data);
                            break;
                        }
                    case Message.SetBoneInert:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneInert can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneInert);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write((float)data);
                            break;
                        }
                    case Message.SetBoneRadius:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneRadius can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneRadius);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write((float)data);
                            break;
                        }
                    case Message.SetBoneEndLength:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneEndLength can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneEndLength);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write((float)data);
                            break;
                        }
                    case Message.SetBoneEndOffset:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneEndOffset can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneEndOffset);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write(((float3)data).x);
                            pipeWriter.Write(((float3)data).y);
                            pipeWriter.Write(((float3)data).z);
                            break;
                        }
                    case Message.SetBoneGravity:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneGravity can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneGravity);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write(((float3)data).x);
                            pipeWriter.Write(((float3)data).y);
                            pipeWriter.Write(((float3)data).z);
                            break;
                        }
                    case Message.SetBoneForce:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneForce can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneForce);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write(((float3)data).x);
                            pipeWriter.Write(((float3)data).y);
                            pipeWriter.Write(((float3)data).z);
                            break;
                        }
                }
                pipe.WaitForPipeDrain();
            }

19 View Source File : IPCSupport.cs
License : GNU General Public License v3.0
Project Creator : 9E4ECDDE

public byte[] ToByteArray()
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    using (BinaryWriter binaryWriter = new BinaryWriter(ms))
                    {
                        binaryWriter.Write(name);
                        binaryWriter.Write(boneCount);
                        List<byte[]> bonesBytes = new List<byte[]>(bones.Select((b) => b.ToByteArray()));
                        foreach (byte[] boneByteData in bonesBytes)
                        {
                            binaryWriter.Write(boneByteData.Length);
                            binaryWriter.Write(boneByteData);
                        }
                        return ms.ToArray();
                    }
                }
            }

19 View Source File : IPCSupport.cs
License : GNU General Public License v3.0
Project Creator : 9E4ECDDE

public void Send(Message messageType, string boneName, object data)
            {
                if (!IsConnected) throw new InvalidOperationException("Tried to send a message but the pipe is disconnected.");
                switch (messageType)
                {
                    case Message.SetBoneData:
                        {
                            if (!IsServer) throw new InvalidOperationException("GetBoneData can only be called from the server.");
                            pipeWriter.Write((int)Message.SetBoneData);
                            pipeWriter.Write((byte[])data);
                            break;
                        }
                    case Message.SetBoneDamping:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneDamping can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneDamping);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write((float)data);
                            break;
                        }
                    case Message.SetBoneElasticity:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneElasticity can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneElasticity);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write((float)data);
                            break;
                        }
                    case Message.SetBoneStiffness:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneStiffness can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneStiffness);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write((float)data);
                            break;
                        }
                    case Message.SetBoneInert:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneInert can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneInert);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write((float)data);
                            break;
                        }
                    case Message.SetBoneRadius:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneRadius can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneRadius);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write((float)data);
                            break;
                        }
                    case Message.SetBoneEndLength:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneEndLength can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneEndLength);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write((float)data);
                            break;
                        }
                    case Message.SetBoneEndOffset:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneEndOffset can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneInert);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write(((float3)data).x);
                            pipeWriter.Write(((float3)data).y);
                            pipeWriter.Write(((float3)data).z);
                            break;
                        }
                    case Message.SetBoneGravity:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneGravity can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneGravity);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write(((float3)data).x);
                            pipeWriter.Write(((float3)data).y);
                            pipeWriter.Write(((float3)data).z);
                            break;
                        }
                    case Message.SetBoneForce:
                        {
                            if (IsServer) throw new InvalidOperationException("SetBoneForce can only be called from the client.");
                            pipeWriter.Write((int)Message.SetBoneInert);
                            pipeWriter.Write(boneName);
                            pipeWriter.Write(((float3)data).x);
                            pipeWriter.Write(((float3)data).y);
                            pipeWriter.Write(((float3)data).z);
                            break;
                        }
                }

            }

19 View Source File : IPCSupport.cs
License : GNU General Public License v3.0
Project Creator : 9E4ECDDE

public unsafe byte[] ToByteArray()
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    using (BinaryWriter binaryWriter = new BinaryWriter(ms))
                    {
                        binaryWriter.Write(name);
                        binaryWriter.Write(damping);
                        binaryWriter.Write(elasticity);
                        binaryWriter.Write(stiffness);
                        binaryWriter.Write(inert);
                        binaryWriter.Write(radius);
                        binaryWriter.Write(endLength);
                        binaryWriter.Write(endOffset.x);
                        binaryWriter.Write(endOffset.y);
                        binaryWriter.Write(endOffset.z);
                        binaryWriter.Write(gravity.x);
                        binaryWriter.Write(gravity.y);
                        binaryWriter.Write(gravity.z);
                        binaryWriter.Write(force.x);
                        binaryWriter.Write(force.y);
                        binaryWriter.Write(force.z);
                        return ms.ToArray();
                    }
                }
            }

19 View Source File : UmaTPose.cs
License : Apache License 2.0
Project Creator : A7ocin

private void Serialize(BinaryWriter bn, HumanLimit value)
	    {
	        bn.Write(value.axisLength);
	        Serialize(bn,value.center);
	        Serialize(bn,value.max);
	        Serialize(bn,value.min);
	        bn.Write(value.useDefaultValues);
	    }

19 View Source File : UmaTPose.cs
License : Apache License 2.0
Project Creator : A7ocin

private void Serialize(BinaryWriter bn, SkeletonBone bone)
	    {
	        bn.Write(bone.name);
	        Serialize(bn, bone.position);
	        Serialize(bn, bone.rotation);
	        Serialize(bn, bone.scale);
	        bn.Write((int)1);
	    }

19 View Source File : UmaTPose.cs
License : Apache License 2.0
Project Creator : A7ocin

private void Serialize(BinaryWriter bn, Quaternion value)
	    {
	        bn.Write(value.x);
	        bn.Write(value.y);
	        bn.Write(value.z);
	        bn.Write(value.w);
	    }

See More Examples