C# Stream.WriteByte的代码示例

通过代码示例来学习C# Stream.WriteByte方法

通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。


Stream.WriteByte是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的Stream.WriteByte() 已经帮大家高亮显示了,大家可以重点学习Stream.WriteByte() 方法的写法,从而快速掌握该方法的应用。

Stream.WriteByte的代码示例1 - urlEncode()

    using System.IO;

    private static void urlEncode (byte b, Stream output)
    {
      if (b > 31 && b < 127) {
        var c = (char) b;
        if (c == ' ') {
          output.WriteByte ((byte) '+');
          return;
        }

        if (isNumeric (c)) {
          output.WriteByte (b);
          return;
        }

        if (isAlphabet (c)) {
          output.WriteByte (b);
          return;
        }

        if (isUnreserved (c)) {
          output.WriteByte (b);
          return;
        }
      }

      var i = (int) b;
      var bytes = new byte[] {
                    (byte) '%',
                    (byte) _hexChars[i >> 4],
                    (byte) _hexChars[i & 0x0F]
                  };

      output.Write (bytes, 0, 3);
    }
    

开发者ID:ntminer,项目名称:NtMiner,代码行数:36,代码来源:HttpUtility.cs

在urlEncode()方法中,Stream的代码示例类中的WriteByte的代码示例方法一共出现了4次, 见黄色背景高亮显示的地方,欢迎大家点赞

Stream.WriteByte的代码示例2 - InitializeMStream()

    using System.IO;
        #endregion

        #region Methods
        /// 
        /// Initialize stream and hexeditor
        /// 
        private void InitializeMStream(HexEditor hexeditor, byte[] findData = null)
        {
            hexeditor.CloseProvider();

            var ms = new MemoryStream(1);

            if (findData is not null && findData.Length > 0)
                foreach (var b in findData)
                    ms.WriteByte(b);
            else
                ms.WriteByte(0);

            hexeditor.Stream = ms;
        }
    

开发者ID:abbaye,项目名称:WpfHexEditorControl,代码行数:21,代码来源:FindReplaceWindow.xaml.cs

在InitializeMStream()方法中,Stream的代码示例类中的WriteByte的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞

Stream.WriteByte的代码示例3 - InitializeMStream()

    using System.IO;

        /// 
        /// Initialize stream and hexeditor
        /// 
        private void InitializeMStream(byte[] findData = null)
        {
            FindHexEdit.CloseProvider();

            _findMs = new MemoryStream(1);

            if (findData is not null && findData.Length > 0)
                foreach (var b in findData)
                    _findMs.WriteByte(b);
            else
                _findMs.WriteByte(0);

            FindHexEdit.Stream = _findMs;
        }
    

开发者ID:abbaye,项目名称:WpfHexEditorControl,代码行数:19,代码来源:FindWindow.xaml.cs

在InitializeMStream()方法中,Stream的代码示例类中的WriteByte的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞

Stream.WriteByte的代码示例4 - ExportDDS()

    using System.IO;

		public static void ExportDDS(BinaryReader sourceReader, Stream destination, DDSContainerParameters @params)
		{
			if(IsRGBA32(@params))
			{
				ExportRGBA32ToDDS(sourceReader, destination, @params);
			}
			else if(IsARGB32(@params))
			{
				ExportARGB32ToDDS(sourceReader, destination, @params);
			}
			else if(IsRGBA16(@params))
			{
				ExportRGBA16ToDDS(sourceReader, destination, @params);
			}
			else if(IsAlpha8(@params))
			{
				ExportAlpha8ToDDS(sourceReader, destination, @params);
			}
			else if(IsR8(@params))
			{
				ExportR8ToDDS(sourceReader, destination, @params);
			}
			else if (IsR16(@params))
			{
				ExportR16ToDDS(sourceReader, destination, @params);
			}
			else if (IsRG16(@params))
			{
				ExportRG16ToDDS(sourceReader, destination, @params);
			}
			else
			{
				ExportDDSHeader(destination, @params);
				for (int i = 0; i < @params.DataLength; i += 2)
				{
					ushort value = sourceReader.ReadUInt16();
					byte value0 = unchecked((byte)(value >> 0));
					byte value1 = unchecked((byte)(value >> 8));
					destination.WriteByte(value0);
					destination.WriteByte(value1);
				}
			}
		}
    

开发者ID:mafaca,项目名称:UtinyRipper,代码行数:45,代码来源:DDSContainer.cs

在ExportDDS()方法中,Stream的代码示例类中的WriteByte的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞

Stream.WriteByte的代码示例5 - Write()

    using System.IO;

		public void Write(Stream stream, SerializedFileHeader header)
		{
			bool swapEndianess = header.Endianess;
			if (HasEndian(header.Version))
			{
				stream.WriteByte((byte)(SwapEndianess ? 1 : 0));
				swapEndianess = SwapEndianess;
			}
			EndianType endianess = swapEndianess ? EndianType.BigEndian : EndianType.LittleEndian;
			using (SerializedWriter writer = new SerializedWriter(stream, endianess, header.Version))
			{
				Write(writer);
			}
		}
    

开发者ID:mafaca,项目名称:UtinyRipper,代码行数:16,代码来源:SerializedFileMetadata.cs

在Write()方法中,Stream的代码示例类中的WriteByte的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

Stream.WriteByte的代码示例6 - GetRequest()

    using System.IO;

        /// 发出请求
        /// 
        /// 
        /// 
        /// 原始参数,仅用于输出日志
        /// 
        protected virtual void GetRequest(Stream ms, String cmd, Packet[] args, Object[] oriArgs)
        {
            // *\r\n$\r\n\r\n
            // *1\r\n$4\r\nINFO\r\n

            var log = Log == null || Log == Logger.Null ? null : Pool.StringBuilder.Get();
            log?.Append(cmd);

            /*
             * 一颗玲珑心
             * 九天下凡尘
             * 翩翩起菲舞
             * 霜摧砺石开
             */

            // 区分有参数和无参数
            if (args == null || args.Length == 0)
            {
                //var str = "*1\r\n${0}\r\n{1}\r\n".F(cmd.Length, cmd);
                ms.Write(GetHeaderBytes(cmd, 0));
            }
            else
            {
                //var str = "*{2}\r\n${0}\r\n{1}\r\n".F(cmd.Length, cmd, 1 + args.Length);
                ms.Write(GetHeaderBytes(cmd, args.Length));

                for (var i = 0; i < args.Length; i++)
                {
                    var item = args[i];
                    var size = item.Total;
                    var sizes = size.ToString().GetBytes();

                    // 指令日志。简单类型显示原始值,复杂类型显示序列化后字符串
                    if (log != null)
                    {
                        log.Append(' ');
                        var ori = oriArgs?[i];
                        switch (ori.GetType().GetTypeCode())
                        {
                            case TypeCode.Object:
                                log.AppendFormat("[{0}]{1}", size, item.ToStr(null, 0, 1024)?.TrimEnd());
                                break;
                            case TypeCode.DateTime:
                                log.Append(((DateTime)ori).ToString("yyyy-MM-dd HH:mm:ss.fff"));
                                break;
                            default:
                                log.Append(ori);
                                break;
                        }
                    }

                    //str = "${0}\r\n".F(item.Length);
                    //ms.Write(str.GetBytes());
                    ms.WriteByte((Byte)'$');
                    ms.Write(sizes);
                    ms.Write(_NewLine);
                    //ms.Write(item);
                    item.CopyTo(ms);
                    ms.Write(_NewLine);
                }
            }
            if (log != null) WriteLog("=> {0}", log.Put(true));
        }
    

开发者ID:NewLifeX,项目名称:X,代码行数:71,代码来源:RedisClient.cs

在GetRequest()方法中,Stream的代码示例类中的WriteByte的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

Stream.WriteByte的代码示例7 - WriteHeaderBlock()

    using System.IO;

        /// 
        /// Writes the header block of the animated gif to the stream.
        /// 
        /// The source gif.
        /// The width of the image.
        /// The height of the image.
        private void WriteHeaderBlock(Stream sourceGif, int width, int height)
        {
            // File Header signature and version.
            this.imageStream.Write(FileType, 0, FileType.Length);

            // Write the logical screen descriptor.
            this.WriteShort(width); // Initial Logical Width
            this.WriteShort(height); // Initial Logical Height

            // Read the global color table info.
            sourceGif.Position = SourceGlobalColorInfoPosition;
            this.WriteByte(sourceGif.ReadByte());

            this.WriteByte(255); // Background Color Index
            this.WriteByte(0); // Pixel aspect ratio
            this.WriteColorTable(sourceGif);

            // Application Extension Header
            int count = this.repeatCount;
            if (count != 1)
            {
                // 0 means loop indefinitely. count is set as play n + 1 times.
                count = Math.Max(0, count - 1);
                this.WriteShort(ApplicationExtensionBlockIdentifier);
                this.WriteByte(ApplicationBlockSize);

                this.imageStream.Write(ApplicationIdentification, 0, ApplicationIdentification.Length);
                this.WriteByte(3); // Application block length
                this.WriteByte(1);
                this.WriteShort(count); // Repeat count for images.

                this.WriteByte(0); // Terminator
            }
        }
    

开发者ID:JimBobSquarePants,项目名称:ImageProcessor,代码行数:42,代码来源:GifEncoder.cs

在WriteHeaderBlock()方法中,Stream的代码示例类中的WriteByte的代码示例方法一共出现了7次, 见黄色背景高亮显示的地方,欢迎大家点赞

Stream.WriteByte的代码示例8 - WriteData()

    using System.IO;

        //public void Write(Stream stream)
        //{
        //    try
        //    {
        //        new IntegerField(_bat_count_offset, _bat_count, _data);
        //        new IntegerField(_property_start_offset, _property_start, _data);
        //        new IntegerField(_sbat_start_offset, _sbat_start, _data);
        //        new IntegerField(_sbat_block_count_offset, _sbat_count, _data);
        //        new IntegerField(_xbat_start_offset, _xbat_start, _data);
        //        new IntegerField(_xbat_count_offset, _xbat_count, _data);

        //        stream.Write(_data, 0, 512);

        //        for (int i = POIFSConstants.SMALLER_BIG_BLOCK_SIZE; i < bigBlockSize.GetBigBlockSize(); i++)
        //        {
        //            //stream.Write(Write(0);
        //            stream.WriteByte(0);
        //        }
        //    }
        //    catch (IOException ex)
        //    {
        //        throw ex;
        //    }
        //}

        public void WriteData(Stream stream)
        {
            try
            {
                new IntegerField(_bat_count_offset, _bat_count, _data);
                new IntegerField(_property_start_offset, _property_start, _data);
                new IntegerField(_sbat_start_offset, _sbat_start, _data);
                new IntegerField(_sbat_block_count_offset, _sbat_count, _data);
                new IntegerField(_xbat_start_offset, _xbat_start, _data);
                new IntegerField(_xbat_count_offset, _xbat_count, _data);

                stream.Write(_data, 0, 512);

                for (int i = POIFSConstants.SMALLER_BIG_BLOCK_SIZE; i < bigBlockSize.GetBigBlockSize(); i++)
                {
                    //stream.Write(Write(0);
                    stream.WriteByte(0);
                }
            }
            catch (IOException ex)
            {
                throw ex;
            }
        }
    

开发者ID:dotnetcore,项目名称:NPOI,代码行数:51,代码来源:HeaderBlock.cs

在WriteData()方法中,Stream的代码示例类中的WriteByte的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞

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