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


C# EndianBinaryWriter类代码示例

本文整理汇总了C#中EndianBinaryWriter的典型用法代码示例。如果您正苦于以下问题:C# EndianBinaryWriter类的具体用法?C# EndianBinaryWriter怎么用?C# EndianBinaryWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: writeWmfAuxPixelData

 private static void writeWmfAuxPixelData(EndianBinaryWriter writer, WmfFile file, WmfPixelInfo pixel)
 {
     if (file.header.auxDataType > 0)
     {
         writer.Write(pixel.waterTypeId);
         writer.Write(pixel.waterBodyIndex);
     }
 }
开发者ID:Celludriel,项目名称:L3DT_Filemanager,代码行数:8,代码来源:WmfManager.cs

示例2: Update

        static void Update(object o)
        {
            int count = 0;
            int max = MinecraftServer.MaxSlots;
            List<string> players = new List<string>();
            foreach (Client p in PlayerList.List)
            {
                if (p.MinecraftUsername == "Player")
                    continue;
                if (p.Settings.Cloaked != null)
                    continue;
                count ++;
                players.Add(p.Name);
                if (p.Session is VanillaSession == false)
                    max ++;
            }

            using (MemoryStream ms = new MemoryStream())
            {
                ms.WriteByte(0xff);
                EndianBinaryWriter w = new EndianBinaryWriter(EndianBitConverter.Big, ms);
                WriteString16(w, 
                    "§1\0" +
                    ((int)MinecraftServer.FrontendVersion).ToString() + "\0" +
                    MinecraftServer.FrontendVersion.ToText() + "\0" +
                    (MinecraftServer.PingReplyMessage ?? "Hi") + "\0" +
                    count + "\0" + max);

                cache = ms.ToArray();
                //Debug.WriteLine(BitConverter.ToString(cache));
            }
        }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:32,代码来源:LegacyStatus.cs

示例3: SaveGame

        public void SaveGame()
        {
            if (isSaving()) {
                Log.Debug("Already doing a save: " + tempSavePath);
            }

            String name = Guid.NewGuid().ToString();

            Log.Debug("Request save: " + name);

            currentSaveData = new MemoryStream();
            BZip2Stream bzip = new BZip2Stream(currentSaveData, CompressionMode.Compress);

            saveWriter = new EndianBinaryWriter(new BigEndianBitConverter(),bzip, Encoding.UTF8);

            saveWriter.Write((byte)formatVersion);

            saveWriter.Write(Singleton<SimulationManager>.instance.m_metaData.m_CityName);
            saveWriter.Write(Singleton<EconomyManager>.instance.LastCashAmount);
            saveWriter.Write(Singleton<EconomyManager>.instance.LastCashDelta);

            int population = (int)Singleton<DistrictManager>.instance.m_districts.m_buffer[0].m_populationData.m_finalCount;
            saveWriter.Write(population);

            var timeSpan = (Singleton<SimulationManager>.instance.m_currentGameTime - new DateTime(1970, 1, 1, 0, 0, 0));
            saveWriter.Write(timeSpan.TotalSeconds);

            SavePanel savePanel = UIView.library.Get<SavePanel>("SavePanel");
            tempSavePath = Path.Combine(DataLocation.saveLocation, name + ".crp");

            savePanel.SaveGame(name);
            WaitForSave();
        }
开发者ID:lisa-lionheart,项目名称:SkylinesGuild,代码行数:33,代码来源:SaveGamePublisher.cs

示例4: Write

 public override void Write(EndianBinaryWriter er, CGFXWriterContext c)
 {
     base.Write(er, c);
     if (TextureImage != null) er.Write((uint)4);
     else er.Write((uint)0);
     if (TextureImage != null) TextureImage.Write(er, c);
 }
开发者ID:Ermelber,项目名称:EveryFileExplorer,代码行数:7,代码来源:TXOB.cs

示例5: ByteBuffer

 //Constructors
 public ByteBuffer()
 {
     stream = new MemoryStream();
     bitConverter = new LittleEndianBitConverter();
     writer = new EndianBinaryWriter(bitConverter, stream);
     reader = new EndianBinaryReader(bitConverter, stream);
 }
开发者ID:gbarresi,项目名称:buffer_bci,代码行数:8,代码来源:ByteBuffer.cs

示例6: ToBytes

        public byte[] ToBytes()
        {
            var memory = new MemoryStream();
            var writer = new EndianBinaryWriter(EndianBitConverter.Big, memory);

            switch (Format)
            {
                case BasicHeader.HeaderFormats.F0: //11 bytes
                    writer.Write(EndianBitConverter.Big.GetBytes(TimeStamp), 1, 3);
                    writer.Write(EndianBitConverter.Big.GetBytes(MessageLength), 1, 3);
                    writer.Write((byte) MessageType);
                    writer.Write(EndianBitConverter.Little.GetBytes(MessageStreamId));
                    break;
                case BasicHeader.HeaderFormats.F1: //7 bytes
                    writer.Write(EndianBitConverter.Big.GetBytes(TimeStamp), 1, 3);
                    writer.Write(EndianBitConverter.Big.GetBytes(MessageLength), 1, 3);
                    writer.Write((byte) MessageType);
                    break;
                case BasicHeader.HeaderFormats.F2: //3 bytes
                    writer.Write(EndianBitConverter.Big.GetBytes(TimeStamp), 1, 3);
                    break;
                case BasicHeader.HeaderFormats.F3: //No bytes
                    break;
            }
            return memory.ToArray();
        }
开发者ID:Austech,项目名称:RtmpSharp2,代码行数:26,代码来源:MessageHeader.cs

示例7: Convert

        public void Convert(EndianBinaryWriter writer)
        {
            var jbtWriter = new JbtWriter(writer);

            var zf = new ZipFile(jarFile);

            foreach (ZipEntry ze in zf)
            {
                if (!ze.IsFile) continue;
                if (!ze.Name.EndsWith(".class")) continue;

                var type = new CompileTypeInfo();

                type.Read(zf.GetInputStream(ze));

                var reader = new BinaryReader(zf.GetInputStream(ze));

                var buffer = new byte[ze.Size];
                reader.Read(buffer, 0, (int)ze.Size);

                jbtWriter.Write(type.Name, buffer);
            }

            jbtWriter.Flush();
        }
开发者ID:will14smith,项目名称:JavaCompiler,代码行数:25,代码来源:JbtConverter.cs

示例8: ConvertOgg

        public static Stream ConvertOgg(string inputFile)
        {
            if (needsConversion(inputFile))
            {
                var platform = getPlatform(inputFile);
                EndianBitConverter bitConverter = platform.GetBitConverter();

                using (var outputFileStream = new MemoryStream())
                using (var inputFileStream = File.Open(inputFile, FileMode.Open))
                using (var writer = new EndianBinaryWriter(bitConverter, outputFileStream))
                using (var reader = new EndianBinaryReader(bitConverter, inputFileStream))
                {
                    writer.Write(reader.ReadBytes(4));
                    UInt32 fileSize = reader.ReadUInt32();
                    fileSize -= 8; // We're removing data, so update the size in the header
                    writer.Write(fileSize);
                    writer.Write(reader.ReadBytes(8));
                    writer.Write(66); reader.ReadUInt32(); // New fmt size is 66
                    writer.Write(reader.ReadBytes(16));
                    writer.Write((ushort)48); reader.ReadUInt16(); // New cbSize is 48
                    writer.Write(reader.ReadBytes(6));
                    reader.BaseStream.Seek(8, SeekOrigin.Current); // Skip ahead 8 bytes, we don't want the vorb chunk
                    writer.Write(reader.ReadBytes((int)reader.BaseStream.Length - (int)reader.BaseStream.Position));

                    return new MemoryStream(outputFileStream.GetBuffer(), 0, (int)outputFileStream.Length);
                }
            }

            return File.OpenRead(inputFile);
        }
开发者ID:joshsten,项目名称:rocksmith-custom-song-toolkit,代码行数:30,代码来源:OggFile.cs

示例9: BuildPacket

        public static byte[] BuildPacket(Packets.LicensePlatePacket plateExpected)
        {
            var mem = new MemoryStream();
            var writer = new EndianBinaryWriter(Configuration.EndianBitConverter, mem, Configuration.Encoding);

            var licenseBytes = Configuration.Encoding.GetBytes(plateExpected.LicensePlate.LicenseNumber);

            writer.Write(licenseBytes);
            writer.Write(01u);
            writer.Write((UInt32)plateExpected.CaptureTime.ToBinary());
            writer.Write((UInt32)plateExpected.CaptureLocation.Id);

            int imgCount = plateExpected.EvidenceImageData.Count;
            writer.Write((uint)imgCount);

            var imgData = plateExpected.EvidenceImageData;
            for (int i = 0; i < imgCount; ++i)
            {
                writer.Write((uint)imgData[i].Length);
            }

            for (int i = 0; i < imgCount; ++i)
            {
                writer.Write(imgData[i]);
            }

            return mem.ToArray();
        }
开发者ID:vanan08,项目名称:damany,代码行数:28,代码来源:PacketGenerator.cs

示例10: ToByteArray

        public byte[] ToByteArray()
        {
            using (MemoryStream buffer = new MemoryStream(100))
            {
                using (EndianBinaryWriter bw = new EndianBinaryWriter(new BigEndianBitConverter(), buffer))
                {
                    bw.Write(connection_id);
                    bw.Write(action);
                    bw.Write(transaction_id);
                    bw.Write(info_hash);
                    bw.Write(peer_id);
                    bw.Write(downloaded);
                    bw.Write(left);
                    bw.Write(uploaded);
                    bw.Write(clientEvent);
                    bw.Write(ip.GetAddressBytes());
                    bw.Write(key);
                    bw.Write(num_want);
                    bw.Write(port);
                    bw.Write(extensions);
                }

                return buffer.ToArray();
            }
        }
开发者ID:Dozey,项目名称:Distribution2,代码行数:25,代码来源:UdpAnnounceRequestPacket.cs

示例11: Prepare

 protected override void Prepare(EndianBinaryWriter w)
 {
     WriteVarInt(w, (int)Version);
     WriteString8(w, Host);
     w.Write((ushort)Port);
     WriteVarInt(w, (int)State);
 }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:7,代码来源:Handshake.cs

示例12: Encode

        /// <inheritdoc/>
        public void Encode(ImageBase image, Stream stream)
        {
            Guard.NotNull(image, nameof(image));
            Guard.NotNull(stream, nameof(stream));

            int imageWidth = image.Width;
            int imageHeight = image.Height;
            ushort max = JpegConstants.MaxLength;

            if (imageWidth > max || imageHeight > max)
            {
                throw new ImageFormatException($"Image dimensions exceed maximum allowable bounds of {max}px.");
            }

            using (EndianBinaryWriter writer = new EndianBinaryWriter(new BigEndianBitConverter(), stream))
            {
                this.WriteApplicationHeader(image, writer);
                this.WriteDescreteQuantizationTables(writer);
                this.WriteStartOfFrame(image, writer);
                this.WriteHuffmanTables(writer);
                this.WriteStartOfScan(image, writer);

                writer.Write(new[] { JpegConstants.Markers.XFF, JpegConstants.Markers.EOI });
            }
        }
开发者ID:joaonlopes,项目名称:ThumbnailCreator,代码行数:26,代码来源:JpegEncoder2.cs

示例13: Prepare

 protected override void Prepare(EndianBinaryWriter w)
 {
     WriteString8(w, ServerID);
     WriteVarInt(w, PublicKey.Length);
     w.Write(PublicKey);	
     WriteVarInt(w, VerifyToken.Length);
     w.Write(VerifyToken);         
 }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:8,代码来源:EncryptionRequest.cs

示例14: testWriteString16_nullstring

		public void testWriteString16_nullstring()
		{
			// test that a null string writes no output.
			MemoryStream stream = new MemoryStream();
			EndianBinaryWriter writer = new EndianBinaryWriter(stream);
			writer.WriteString16(null);
			Assert.AreEqual(0, stream.Length);
		}
开发者ID:Redi0,项目名称:meijing-ui,代码行数:8,代码来源:EndianBinaryWriterTest.cs

示例15: Prepare

		protected override void Prepare (EndianBinaryWriter w)
		{
            throw new NotImplementedException();
			/*
            WriteString8(w, Channel);
            Varint w.Write((short)Data.Length);
            w.Write(Data);          */
		}
开发者ID:mctraveler,项目名称:MineSharp,代码行数:8,代码来源:PluginMessageFromServer.cs


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