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


C# Stream.WriteBytes方法代码示例

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


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

示例1: SaveToStream

        protected override void SaveToStream(Stream stream)
        {
            if (Version==0 && 
                (_CreationTime > uint.MaxValue || 
                _ModificationTime > uint.MaxValue || 
                Duration > uint.MaxValue)) Version = 1;

            base.SaveToStream(stream);

            if (Version == 1)
            {
                stream.WriteBEUInt64(_CreationTime);
                stream.WriteBEUInt64(_ModificationTime);
                stream.WriteBEUInt32(TimeScale);
                stream.WriteBEUInt64(Duration);
            }
            else // if(Version == 0)
            {
                stream.WriteBEUInt32(checked((uint)_CreationTime));
                stream.WriteBEUInt32(checked((uint)_ModificationTime));
                stream.WriteBEUInt32(TimeScale);
                stream.WriteBEUInt32(checked((uint)Duration));
            }
            stream.WriteBEInt32(_Rate);
            stream.WriteBEInt16(_Volume);
            stream.WriteBytes(Reserved);
            for (int i = 0; i < 9; i++) stream.WriteBEInt32(Matrix[i]);
            stream.WriteBytes(PreDefined);
            stream.WriteBEUInt32(NextTrackID);
        }
开发者ID:heksesang,项目名称:bmff,代码行数:30,代码来源:MovieHeaderBox.cs

示例2: SaveToStream

        protected override void SaveToStream(Stream stream)
        {
            base.SaveToStream(stream);
            stream.WriteBytes(MajorBrand.GetBytes());
            stream.WriteBEUInt32(MinorVersion);

            foreach (FourCC compatibleBrand in _CompatibleBrands)
            {
                stream.WriteBytes(compatibleBrand.GetBytes());
            }
        }
开发者ID:heksesang,项目名称:bmff,代码行数:11,代码来源:FileTypeBox.cs

示例3: WriteToStream

 public override void WriteToStream(Stream outputStream)
 {
     outputStream
         .WriteBytes((Byte)ASCIIBytes.p)
         .WriteInt32(4 + password.Length)
         .WriteBytes(password);
 }
开发者ID:timoch,项目名称:Npgsql-fdb,代码行数:7,代码来源:NpgsqlPasswordPacket.cs

示例4: WriteToStream

 public override void WriteToStream(Stream outputStream)
 {
     outputStream
         .WriteBytes((byte)FrontEndMessageCode.Describe)
         .WriteInt32(_messageLength)
         .WriteBytes((byte)_whatToDescribe)
         .WriteBytesNullTerminated(_bPortalName);
 }
开发者ID:herqueles3,项目名称:Npgsql,代码行数:8,代码来源:NpgsqlDescribe.cs

示例5: WriteToStream

        public override void WriteToStream(Stream outputStream)
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "WriteToStream");

            outputStream
                .WriteBytes((Byte)ASCIIBytes.p)
                .WriteInt32(4 + password.Length)
                .WriteBytes(password);
        }
开发者ID:baondp,项目名称:Npgsql,代码行数:9,代码来源:NpgsqlPasswordPacket.cs

示例6: WriteBeginRequest

		private static void WriteBeginRequest(Stream Stream)
		{
			Stream.WriteBytes(new byte[]
			{
				1, // Version
				(byte)Fastcgi.PacketType.FCGI_BEGIN_REQUEST, // Type
				0, 1, // RequestId
				0, 8, // Content Length
				0,    // Padding Length
				0,    // Reserved
				1, 2, 3, 4, 5, 6, 7, 8, // Data
			});
		}
开发者ID:soywiz,项目名称:csharputils,代码行数:13,代码来源:FastcgiHandlerTest.cs

示例7: Encode

		public static void Encode(Image image, Stream stream)
		{
			stream.WriteString(image.Header);
			stream.WriteBytes(image.LogicalScreenDescriptor.ToBytes());

			if (image.LogicalScreenDescriptor.GlobalColorTableFlag)
			{
				stream.WriteBytes(image.GlobalColorTable);
			}

			foreach (var applicationExtension in image.ApplictionExtensions)
			{
				stream.WriteBytes(applicationExtension.ToBytes());
			}

			foreach (var commentExtension in image.CommentExtensions)
			{
				stream.WriteBytes(commentExtension.ToBytes());
			}

			WriteFrames(image.Frames, stream);
		}
开发者ID:krabishe,项目名称:GIF89a.Transformation,代码行数:22,代码来源:GifEncoder.cs

示例8: WriteFrames

		private static void WriteFrames(IEnumerable<ImageFrame> frames, Stream stream)
		{
			foreach (var frame in frames)
			{
				var frameBytes = new List<byte>();
				if (frame.GraphicControlExtension != null)
				{
					frameBytes.AddRange(frame.GraphicControlExtension.ToBytes());
				}

				frame.ImageDescriptor.SortFlag = false;
				frame.ImageDescriptor.InterlaceFlag = false;

				frameBytes.AddRange(frame.ImageDescriptor.ToBytes());
				if (frame.ImageDescriptor.LocalColorTableFlag)
				{
					frameBytes.AddRange(frame.LocalColorTable);
				}

				stream.WriteBytes(frameBytes.ToArray());

				var transparentColorIndex = -1;
				if (frame.GraphicControlExtension != null && frame.GraphicControlExtension.TransparentColorFlag)
				{
					transparentColorIndex = frame.GraphicControlExtension.TransparentColorIndex;
				}

				var imageData = GetImageData(frame.Bitmap, frame.LocalColorTable, transparentColorIndex);

				var lzwEncoder = new LzwEncoder(imageData, (byte) frame.ColorDepth);
				lzwEncoder.Encode(stream);

				stream.WriteByte(Const.BlockTerminator);
			}

			stream.WriteByte(Const.EndIntroducer);
		}
开发者ID:krabishe,项目名称:GIF89a.Transformation,代码行数:37,代码来源:GifEncoder.cs

示例9: DecryptIplToMemory

        /// <summary>
        /// 
        /// </summary>
        /// <param name="IplData"></param>
        /// <param name="OutputStream"></param>
        /// <param name="ToMemoryAddress"></param>
        /// <returns></returns>
        public static IplInfo DecryptIplToMemory(byte[] IplData, Stream OutputStream, bool ToMemoryAddress = true)
        {
            var buffer = new byte[0x1000];
            var IplInfo = default(IplInfo);

            //ArrayUtils.HexDump(IplData);

            fixed (byte* IplPtr = IplData)
            fixed (byte* bufferPtr = buffer)
            {
                for (int n = 0; n < IplData.Length; n += 0x1000)
                {
                    var Ptr = IplPtr + n;

                    var Header = *(Kirk.AES128CMACHeader*)Ptr;
                    //Console.WriteLine(Header.DataSize);
                    var Kirk = new Kirk();
                    Kirk.kirk_init();
                    Kirk.kirk_CMD1(bufferPtr, Ptr, 0x1000, do_check: false);
                    var IplBlock = *(IplBlock*)bufferPtr;
                    //Console.WriteLine(IplBlock.ToStringDefault());
                    if (ToMemoryAddress)
                    {
                        OutputStream.Position = IplBlock.LoadAddress;
                        Console.WriteLine("IplBlock.LoadAddress: 0x{0:X8}", IplBlock.LoadAddress);
                    }
                    OutputStream.WriteBytes(PointerUtils.PointerToByteArray(&IplBlock.BlockData, (int)IplBlock.BlockSize));
                    if (IplBlock.EntryFunction != 0)
                    {
                        IplInfo.EntryFunction = IplBlock.EntryFunction;
                    }
                }
            }

            return IplInfo;
        }
开发者ID:soywiz,项目名称:cspspemu,代码行数:43,代码来源:IplReader.cs

示例10: EncodeBits

		private void EncodeBits(Stream stream, BitEncoder bitEncoder, int suffix)
		{
			bitEncoder.Add(suffix);
			bitEncoder.Add(this.endCode);
			bitEncoder.End();

			if (bitEncoder.Length > 255)
			{
				var leftBuffer = new byte[bitEncoder.Length - 255];
				bitEncoder.CopyTo(255, leftBuffer, 0, leftBuffer.Length);
				bitEncoder.Clear();
				bitEncoder.AddRange(leftBuffer);
				stream.WriteByte((byte) leftBuffer.Length);
				stream.WriteBytes(leftBuffer);
			}
			else
			{
				stream.WriteByte((byte) (bitEncoder.Length));
				stream.WriteBytes(bitEncoder.ToArray());
				bitEncoder.Clear();
			}
		}
开发者ID:krabishe,项目名称:GIF89a.Transformation,代码行数:22,代码来源:LzwEncoder.cs

示例11: concatenateFragmentsInto

        private bool concatenateFragmentsInto(Stream destination)
        {
            while (true) {
            var frame = WebSocketFrame.Read (_stream, false);
            var msg = checkIfValidReceivedFrame (frame);
            if (msg != null)
              return processUnsupportedFrame (frame, CloseStatusCode.ProtocolError, msg);

            frame.Unmask ();
            if (frame.IsFinal) {
              /* FINAL */

              // CONT
              if (frame.IsContinuation) {
            destination.WriteBytes (frame.PayloadData.ApplicationData);
            break;
              }

              // PING
              if (frame.IsPing) {
            processPingFrame (frame);
            continue;
              }

              // PONG
              if (frame.IsPong) {
            processPongFrame (frame);
            continue;
              }

              // CLOSE
              if (frame.IsClose)
            return processCloseFrame (frame);
            }
            else {
              /* MORE */

              // CONT
              if (frame.IsContinuation) {
            destination.WriteBytes (frame.PayloadData.ApplicationData);
            continue;
              }
            }

            // ?
            return processUnsupportedFrame (
              frame,
              CloseStatusCode.UnsupportedData,
              "Unsupported data has been received while receiving the fragmented data.");
              }

              return true;
        }
开发者ID:phamquocthang,项目名称:websocket-sharp,代码行数:53,代码来源:WebSocket.cs

示例12: SaveToStream

        protected override void SaveToStream(Stream stream)
        {
            base.SaveToStream(stream);

            stream.WriteBytes(Format.GetBytes());
        }
开发者ID:heksesang,项目名称:bmff,代码行数:6,代码来源:DataCompressionBox.cs

示例13: Serialize


//.........这里部分代码省略.........

                    var sectionDataOffset = 2 + (file.Sections.Count * 6);

                    var sections = new List<KeyValuePair<ushort, int>>();
                    foreach (var section in file.Sections.OrderBy(s => keys.IndexOf(s.Key)))
                    {
                        sections.Add(new KeyValuePair<ushort, int>(
                            (ushort)keys.IndexOf(section.Key), sectionDataOffset));

                        var valueDataOffset = 2 + (section.Value.Count * 6);

                        var values = new List<KeyValuePair<ushort, int>>();
                        foreach (var value in section.Value.OrderBy(v => keys.IndexOf(v.Key)))
                        {
                            index.Position = fileDataOffset + sectionDataOffset + valueDataOffset;

                            values.Add(new KeyValuePair<ushort, int>(
                                (ushort)keys.IndexOf(value.Key), valueDataOffset));

                            index.WriteValueU16((ushort)value.Value.Count, endian);
                            valueDataOffset += 2;

                            foreach (var item in value.Value)
                            {
                                if (item.Type == 1)
                                {
                                    index.WriteValueS32((1 << 29) | bitOffset, endian);
                                }
                                else if (item.Type == 0 || item.Type == 2 || item.Type == 3 || item.Type == 4)
                                {
                                    index.WriteValueS32((item.Type << 29) | bitOffset, endian);
                                    bitOffset += huffmanEncoder.Encode((item.Value ?? "") + '\0', bits, bitOffset);
                                }
                                valueDataOffset += 4;
                            }
                        }

                        index.Position = fileDataOffset + sectionDataOffset;
                        
                        index.WriteValueU16((ushort)values.Count, endian);
                        sectionDataOffset += 2;

                        foreach (var value in values)
                        {
                            index.WriteValueU16(value.Key, endian);
                            index.WriteValueS32(value.Value, endian);
                            sectionDataOffset += 6;
                        }

                        sectionDataOffset += valueDataOffset;
                    }

                    index.Position = fileDataOffset;

                    index.WriteValueU16((ushort)sections.Count, endian);
                    fileDataOffset += 2;

                    foreach (var section in sections)
                    {
                        index.WriteValueU16(section.Key, endian);
                        index.WriteValueS32(section.Value, endian);
                        fileDataOffset += 6;
                    }

                    fileDataOffset += sectionDataOffset;
                }

                index.Position = 0;

                index.WriteValueU16((ushort)files.Count, endian);
                foreach (var file in files)
                {
                    index.WriteValueU16(file.Key, endian);
                    index.WriteValueS32(file.Value, endian);
                }

                index.Position = 0;
                indexSize = (uint)index.Length;

                output.Seek(headerSize + stringTableSize + huffmanSize, SeekOrigin.Begin);
                output.WriteFromStream(index, index.Length);
            }

            output.Seek(headerSize + stringTableSize + huffmanSize + indexSize, SeekOrigin.Begin);
            output.WriteValueS32(bits.Length, endian);
            var bytes = new byte[(bits.Length - 1) / 8 + 1];
            bits.CopyTo(bytes, 0);
            output.WriteBytes(bytes);

            output.Seek(8, SeekOrigin.Begin);
            output.WriteValueS32(maxKeyLength, endian);
            output.WriteValueS32(maxValueLength, endian);
            output.WriteValueU32(stringTableSize, endian);
            output.WriteValueU32(huffmanSize, endian);
            output.WriteValueU32(indexSize, endian);
            output.WriteValueS32(bytes.Length, endian);

            output.Seek(0, SeekOrigin.Begin);
            output.WriteValueU32(0x666D726D, endian);
        }
开发者ID:CreeperLava,项目名称:ME3Explorer,代码行数:101,代码来源:CoalescedFile.cs

示例14: AppendParameterValue

        private void AppendParameterValue(Stream dest, NpgsqlParameter parameter)
        {
            byte[] serialised = parameter.TypeInfo.ConvertToBackend(parameter.NpgsqlValue, false, Connector.NativeToBackendTypeConverterOptions);

            // Add parentheses wrapping parameter value before the type cast to avoid problems with Int16.MinValue, Int32.MinValue and Int64.MinValue
            // See bug #1010543
            // Check if this parenthesis can be collapsed with the previous one about the array support. This way, we could use
            // only one pair of parentheses for the two purposes instead of two pairs.
            dest
                .WriteBytes((byte)ASCIIBytes.ParenLeft)
                .WriteBytes((byte)ASCIIBytes.ParenLeft)
                .WriteBytes(serialised)
                .WriteBytes((byte)ASCIIBytes.ParenRight);

            if (parameter.UseCast)
            {
                dest.WriteString("::{0}", parameter.TypeInfo.CastName);

                if (parameter.TypeInfo.UseSize && (parameter.Size > 0))
                {
                    dest.WriteString("({0})", parameter.Size);
                }
            }

            dest.WriteBytes((byte)ASCIIBytes.ParenRight);
        }
开发者ID:herqueles3,项目名称:Npgsql,代码行数:26,代码来源:NpgsqlCommand.Rewrite.cs

示例15: WriteToStream

 public override void WriteToStream(Stream outputStream)
 {
     outputStream.WriteBytes(pgCommandBytes);
 }
开发者ID:timoch,项目名称:Npgsql-fdb,代码行数:4,代码来源:NpgsqlQuery.cs


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