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


C# IWriter.Write方法代码示例

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


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

示例1: Copy

 public static void Copy(IReader reader, IWriter writer)
 {
     if (reader != null && writer != null)
     {
         string data = reader.Read();
         writer.Write(data);
     }
 }
开发者ID:liupanpansmile,项目名称:AgileDevelopmentStudy,代码行数:8,代码来源:Operation.cs

示例2: DoExport

        private void DoExport(IWriter writer, DateTime start, DateTime end)
        {
            var quotes = _quoteRepository.GetQuotes(start, end);

            foreach (var quote in quotes)
            {
                var data = _formatter.ToString(quote);
                writer.Write(data);
            }
        }
开发者ID:dminik,项目名称:QuoteLoaderTask,代码行数:10,代码来源:QuoteExporter.cs

示例3: PrintMatrix

 public void PrintMatrix(IWriter writer)
 {
     for (int i = 0; i < N; i++)
     {
         for (int j = 0; j < M; j++)
         {
             writer.Write(Value[i, j].ToString());
         }
         writer.WriteLine();
     }
 }
开发者ID:Confirmit,项目名称:Students,代码行数:11,代码来源:Program.cs

示例4: WriteFlatFile

 /// <summary>
 /// Writes the data table contents to the writer.
 /// </summary>
 /// <param name="table">The table whose contents to write to the writer.</param>
 /// <param name="writer">The writer to write the values to.</param>
 /// <exception cref="System.ArgumentNullException">The table is null.</exception>
 /// <exception cref="System.ArgumentNullException">The writer is null.</exception>
 public static void WriteFlatFile(this DataTable table, IWriter writer)
 {
     if (table == null)
     {
         throw new ArgumentNullException("table");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     ISchema schema = writer.GetSchema();
     foreach (DataRow row in table.Rows)
     {
         object[] values = new object[schema.ColumnDefinitions.Count];
         for (int index = 0; index != values.Length; ++index)
         {
             ColumnDefinition column = schema.ColumnDefinitions[index];
             values[index] = row[column.ColumnName];
         }
         writer.Write(values);
     }
 }
开发者ID:BjornNordblom,项目名称:FlatFiles,代码行数:29,代码来源:DataTableExtensions.cs

示例5: Write

 public static void Write(IWriter writer, string entryPath, Stream source)
 {
     writer.Write(entryPath, source, null);
 }
开发者ID:RainsSoft,项目名称:sharpcompress,代码行数:4,代码来源:IWriterExtensions.cs

示例6: WriteTypeUsingType

        private void WriteTypeUsingType(object toWrite, IWriter writer)
        {
            foreach (var field in type.GetAllFields())
            {
                if (!CanWriteField(field))
                    continue;

                object fieldValue = field.GetValue(toWrite);
                writer.Write(fieldValue);
            }
        }
开发者ID:TheFlyingFiddle,项目名称:Project-Monocle,代码行数:11,代码来源:ReflectionTypeWriter.cs

示例7: WriteTypeUsingCtor

        private void WriteTypeUsingCtor(object toWrite, IWriter writer)
        {
            foreach (var parameter in ctor.GetParameters())
            {
                FieldInfo field;
                if(TryGetField(parameter.Name, out field))
                {
                    object fieldValue = field.GetValue(toWrite);
                    writer.Write(fieldValue);
                    continue;
                }

                PropertyInfo property;
                if (TryGetProperty(parameter.Name, out property))
                {
                    object propertyValue = property.GetValue(toWrite, null);
                    writer.Write(propertyValue);
                    continue;
                }

                throw new ArgumentException(string.Format("Could not find a field or property named : {0}.", parameter.Name));
            }
        }
开发者ID:TheFlyingFiddle,项目名称:Project-Monocle,代码行数:23,代码来源:ReflectionTypeWriter.cs

示例8: Render

 /// <summary>
 /// Renders this element to the html writer.
 /// </summary>
 /// <param name="writer">The html writer this element and it's children are rendered.</param>
 /// <example>
 /// string expected = @"<span>Hello World</span>";
 /// string actual = "";
 /// using (StringWriter writer = new StringWriter())
 /// using (HtmlTextWriter html = new HtmlTextWriter(writer))
 /// {
 /// new Element("span")
 /// .Update("Hello World")
 /// .Render(html);
 /// actual = writer.ToString();
 /// }
 /// Assert.AreEqual(expected, actual);
 /// </example>
 public override void Render(IWriter writer)
 {
     writer.Write(Text);
 }
开发者ID:chrcar01,项目名称:HtmlBuilder,代码行数:21,代码来源:TextElement.cs

示例9: WriteType

 public void WriteType(object toWrite, IWriter writer)
 {
     writer.Write((int)toWrite);
 }
开发者ID:TheFlyingFiddle,项目名称:Project-Monocle,代码行数:4,代码来源:EnumTypeWriter.cs

示例10: RenderContent

        /// <summary>
        /// Renders the content.
        /// </summary>
        /// <param name="html">The HtmlBuilder.</param>
        protected virtual void RenderContent(IWriter html)
        {
            if (String.IsNullOrEmpty(this.InnerHtml))
                return;

            html.Write(this.InnerHtml);
            //this.WriteEndOfLineChar(html);
        }
开发者ID:chrcar01,项目名称:HtmlBuilder,代码行数:12,代码来源:Element.cs

示例11: Write

 public void Write(IWriter writer)
 {
     writer.Write(_value);
 }
开发者ID:Confirmit,项目名称:Students,代码行数:4,代码来源:WriteValueCommand.cs

示例12: IncrementAndAppendChar

 private int IncrementAndAppendChar(IWriter output, char ch)
 {
     var count = 1;
       if (!this.unlimitedLineLength) {
     if (this.lineCount + 1 > 75) {
       // 76 including the final '='
       byte[] buf;
       if (ch == '.') {
     buf = new byte[] { 0x3d, 0x0d, 0x0a, (byte)'=',
     (byte)'2', (byte)'E' };
       } else {
     buf = new byte[] { 0x3d, 0x0d, 0x0a, (byte)ch };
       }
       output.Write(buf, 0, buf.Length);
       this.lineCount = buf.Length - 3;
       return buf.Length;
     }
       }
       if (this.lineCount == 0 && ch == '.') {
     output.WriteByte((byte)'=');
     output.WriteByte((byte)'2');
     output.WriteByte((byte)'E');
     this.lineCount += 2;
     count += 2;
       } else {
     output.WriteByte((byte)ch);
       }
       ++this.lineCount;
       return count;
 }
开发者ID:peteroupc,项目名称:MailLib,代码行数:30,代码来源:QuotedPrintableEncoder.cs

示例13: Write

        internal void Write(IWriter writer)
        {
            Signature = ZipConstants.ZipEntrySignature;

            // 取得数据流位置
            RelativeOffsetOfLocalHeader = (UInt32)writer.Stream.Position;

            if (IsDirectory)
            {
                // 写入头部
                writer.WriteObject(this);

                return;
            }

            Int32 dsLen = (Int32)DataSource.Length;
            //if (dsLen <= 0) CompressionMethod = CompressionMethod.Stored;

            // 计算签名和大小
            if (Crc == 0) Crc = DataSource.GetCRC();
            if (UncompressedSize == 0) UncompressedSize = (UInt32)dsLen;
            if (CompressionMethod == CompressionMethod.Stored) CompressedSize = UncompressedSize;
            if (DataSource.IsCompressed) CompressedSize = (UInt32)dsLen;

            // 写入头部
            writer.WriteObject(this);

            // 没有数据,直接跳过
            if (dsLen <= 0) return;

            #region 写入文件数据
#if DEBUG
            var ts = writer.Stream as NewLife.Log.TraceStream;
            if (ts != null) ts.UseConsole = false;
#endif

            // 数据源。只能用一次,因为GetData的时候把数据流移到了合适位置
            Stream source = DataSource.GetData();
            switch (CompressionMethod)
            {
                case CompressionMethod.Stored:
                    // 原始数据流直接拷贝到目标。必须指定大小,否则可能读过界
                    source.CopyTo(writer.Stream, 0, dsLen);
                    break;
                case CompressionMethod.Deflated:
                    if (DataSource.IsCompressed)
                    {
                        // 可能数据源是曾经被压缩过了的,比如刚解压的实体
                        source.CopyTo(writer.Stream, 0, dsLen);
                    }
                    else
                    {
                        // 记录数据流位置,待会用来计算已压缩大小
                        Int64 p = writer.Stream.Position;
                        using (var stream = new DeflateStream(writer.Stream, CompressionMode.Compress, true))
                        {
                            source.CopyTo(stream);
                            stream.Close();
                        }
                        CompressedSize = (UInt32)(writer.Stream.Position - p);
#if DEBUG
                        if (ts != null) ts.UseConsole = true;
#endif

                        // 回头重新修正压缩后大小CompressedSize
                        p = writer.Stream.Position;
                        // 计算好压缩大小字段所在位置
                        writer.Stream.Seek(RelativeOffsetOfLocalHeader + 18, SeekOrigin.Begin);
                        writer.Write(CompressedSize);
                        writer.Stream.Seek(p, SeekOrigin.Begin);
                    }

                    break;
                default:
                    throw new XException("无法处理的压缩算法{0}!", CompressionMethod);
            }
#if DEBUG
            if (ts != null) ts.UseConsole = true;
#endif
            #endregion
        }
开发者ID:windygu,项目名称:asxinyunet,代码行数:81,代码来源:ZipEntry.cs

示例14: StatusCommand

 private static void StatusCommand(IWriter output, BlobDatabase database)
 {
     StringBuilder sb = new StringBuilder();
     foreach (var blob in database)
     {
         sb.AppendLine(blob.ToString());
     }
     output.Write(sb.ToString());
 }
开发者ID:HouseBreaker,项目名称:SoftUni-Exams,代码行数:9,代码来源:CommandParser.cs

示例15: WriteTo

        /// <summary>
        /// WriteTo implements the WriterTo interface and
        /// serializes the Command to the supplied Writer.
        ///
        /// It is suggested that the target Writer is buffered
        /// to avoid performing many system calls.
        /// </summary>
        internal long WriteTo(IWriter w, byte[] buf)
        {
            int j = 0;

            int count = Name.Length;
            Buffer.BlockCopy(Name, 0, buf, j, count);
            j += count;

            if (Params != null)
            {
                foreach (var param in Params)
                {
                    buf[j++] = byteSpace;
                    count = param.Length;
                    Buffer.BlockCopy(param, 0, buf, j, count);
                    j += count;
                }
            }

            buf[j++] = byteNewLine;

            if (Body != null)
            {
                _bigEndian.PutUint32(buf, Body.Length, j);
                j += 4;

                count = Body.Length;
                Buffer.BlockCopy(Body, 0, buf, j, count);
                j += count;
            }

            return w.Write(buf, 0, j);
        }
开发者ID:yonglehou,项目名称:NsqSharp,代码行数:40,代码来源:Command.cs


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