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


C# System.IO.StringWriter.ToString方法代码示例

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


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

示例1: CheckCompressionRoundTrip

        private void CheckCompressionRoundTrip(IGraph g)
        {
            foreach (KeyValuePair<IRdfWriter, IRdfReader> kvp in this._compressers)
            {

                IRdfWriter writer = kvp.Key;
                if (writer is ICompressingWriter)
                {
                    ((ICompressingWriter)writer).CompressionLevel = WriterCompressionLevel.High;
                }
                if (writer is IHighSpeedWriter)
                {
                    ((IHighSpeedWriter)writer).HighSpeedModePermitted = false;
                }
                System.IO.StringWriter strWriter = new System.IO.StringWriter();
                writer.Save(g, strWriter);

                Console.WriteLine("Compressed Output using " + kvp.Key.GetType().Name);
                Console.WriteLine(strWriter.ToString());
                Console.WriteLine();

                Graph h = new Graph();
                StringParser.Parse(h, strWriter.ToString(), kvp.Value);

                Assert.AreEqual(g, h, "Graphs should be equal after round trip to and from serialization using " + kvp.Key.GetType().Name);
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:27,代码来源:CollectionCompressionTests.cs

示例2: Extract

        public TextExtractionResult Extract(Func<Metadata, InputStream> streamFactory)
        {
            try
            {
                var parser = new AutoDetectParser();
                var metadata = new Metadata();
                var parseContext = new ParseContext();

                //use the base class type for the key or parts of Tika won't find a usable parser
                parseContext.set(typeof(Parser), parser);

                var content = new System.IO.StringWriter();
                var contentHandlerResult = new TextExtractorContentHandler(content);

                using (var inputStream = streamFactory(metadata))
                {
                    try
                    {
                        parser.parse(inputStream, contentHandlerResult, metadata, parseContext);
                    }
                    finally
                    {
                        inputStream.close();
                    }
                }

                return AssembleExtractionResult(content.ToString(), metadata);
            }
            catch (Exception ex)
            {
                throw new TextExtractionException("Extraction failed.", ex);
            }
        }
开发者ID:KevM,项目名称:tikaondotnet,代码行数:33,代码来源:TextExtractor.cs

示例3: GenerateString

		// This method is OPTIONAL
		//
		/// <summary>Executes the template and returns the output as a string.</summary>
		/// <returns>The template output.</returns>
		public string GenerateString ()
		{
			using (var sw = new System.IO.StringWriter ()) {
				Generate (sw);
				return sw.ToString ();
			}
		}
开发者ID:jtrent238,项目名称:My-App,代码行数:11,代码来源:Razor1.cs

示例4: ConvertToJsonString

 public string ConvertToJsonString(object obj)
 {
     JsonSerializer js = new JsonSerializer();
     System.IO.TextWriter tw = new System.IO.StringWriter();
     js.Serialize(tw, obj);
     return tw.ToString();
 }
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:7,代码来源:GetLineStatus.ashx.cs

示例5: Serialize

 /// <summary>
 /// Serializes an object as a string.
 /// </summary>
 public static string Serialize(object json)
 {
     var sb = new System.Text.StringBuilder();
     var sw = new System.IO.StringWriter(sb);
     SerializeTo(json, sw);
     return sw.ToString();
 }
开发者ID:edbutler,项目名称:papika-telemetry,代码行数:10,代码来源:MicroJSON.cs

示例6: Render

 /// <summary>
 /// 模版文件名
 /// </summary>
 /// <param name="templatefile"></param>
 /// <returns></returns>
 public string Render(string templatefile)
 {
     Template tmp = velocity.GetTemplate(templatefile);
     System.IO.StringWriter writer = new System.IO.StringWriter();
     tmp.Merge(context, writer);
     return writer.ToString();
 }
开发者ID:nkaluva,项目名称:helper,代码行数:12,代码来源:VelocityHelper.cs

示例7: generate_visualizers

        public void generate_visualizers()
        {
            var path = @"C:\code\diagnostics\src\FubuMVC.Diagnostics\Visualization\Visualizers\ConfigurationActions";

            var types = typeof (FubuRequest).Assembly.GetExportedTypes()
                .Where(x => x.IsConcreteTypeOf<IConfigurationAction>());

            var fileSystem = new FileSystem();

            types.Each(x =>
            {
                var writer = new StringWriter();
                /*
            <use master="" />
            <viewdata model="FubuMVC.Diagnostics.Visualization.BehaviorNodeViewModel" />
                 */
                writer.WriteLine("<use master=\"\" />");
                writer.WriteLine("<viewdata model=\"{0}\" />", x.FullName);

                var file = path.AppendPath(x.Name + ".spark");

                fileSystem.WriteStringToFile(file, writer.ToString());

            });
        }
开发者ID:jbogard,项目名称:fubumvc,代码行数:25,代码来源:debugging.cs

示例8: ObjetoSerializado

 public static string ObjetoSerializado(Object Objeto)
 {
     System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(Objeto.GetType());
     System.IO.StringWriter textWriter = new System.IO.StringWriter();
     x.Serialize(textWriter, Objeto);
     return textWriter.ToString();
 }
开发者ID:pjeconde,项目名称:condeco,代码行数:7,代码来源:Funciones.cs

示例9: FillDataSets

        public void FillDataSets(NBADWDataEntryApplication.dsDE_ESAFSiteList dataSet1)
        {
            // Turn off constraint checking before the dataset is filled.
            // This allows the adapters to fill the dataset without concern
            // for dependencies between the tables.
            dataSet1.EnforceConstraints = false;
            try
            {
                // Open the connection.
                this.oleDbConnection1.Open();
                // Attempt to fill the dataset through the OleDbDataAdapter1.
                this.oleDbdaDE_ESAFSiteList.Fill(dataSet1);
            }
            catch (System.Exception fillException)
            {
                // Add your error handling code here.
                throw fillException;
            }
            finally
            {
                // Turn constraint checking back on.
                dataSet1.EnforceConstraints = true;
                // Close the connection whether or not the exception was thrown.
                this.oleDbConnection1.Close();

                System.IO.StringWriter sw1 = new System.IO.StringWriter();

                // Write the DataSet to the ViewState property.
                dataSet1.WriteXml(sw1);
                ViewState["dSet1"] = sw1.ToString();
            }
        }
开发者ID:nbadw,项目名称:old_data_entry,代码行数:32,代码来源:ESAFList.aspx.cs

示例10: btnexporttoexc_Click

        protected void btnexporttoexc_Click(object sender, EventArgs e)
        {
            string strFileName = txtJobNo.Text + ".xls";
            try
            {
                if ((gvSEW.Rows.Count != 0) || (gvSEW.Rows.Count != 0))
                {
                    string na = "GoodsReceiptNote.xls";
                    string ExcelExport = na;
                    // Export(ExcelExport, GridView1);
                    Response.Clear();
                    Response.Buffer = true;
                    Response.AddHeader("content-disposition", "attachment;filename= " + strFileName + "");
                    Response.Charset = "";
                    Response.ContentType = "application/vnd.ms-excel";
                    System.IO.StringWriter stringWrite = new System.IO.StringWriter();
                    System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
                    pnlGrid.RenderControl(htmlWrite);
                    Response.Output.Write(stringWrite.ToString());
                    Response.Flush();
                    Response.End();
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Key", "alert('No Records Found EXCEL Report Cannot be generated!.');", true);
                }
            }
            catch (Exception)
            {

            }
        }
开发者ID:manivts,项目名称:impexcubeapp,代码行数:32,代码来源:frmSEWDSR.aspx.cs

示例11: DataTable2Excel

        /// <summary>
        /// 把DataTable内容导出伟excel并返回客户端
        /// </summary>
        /// <param name="dgData">待导出的DataTable</param>
        /// 创 建 人:陈文凯
        /// 创建日期:2005年10月08日
        /// 修 改 人:
        /// 修改日期:
        public static void DataTable2Excel(System.Data.DataTable dtData)
        {
            System.Web.UI.WebControls.DataGrid dgExport = null;
            // 当前对话
            System.Web.HttpContext curContext = System.Web.HttpContext.Current;
            // IO用于导出并返回excel文件
            System.IO.StringWriter strWriter = null;
            System.Web.UI.HtmlTextWriter htmlWriter = null;

            if (dtData != null)
            {
                // 设置编码和附件格式
                curContext.Response.ContentType = "application/vnd.ms-excel";
                curContext.Response.ContentEncoding =System.Text.Encoding.UTF8;
                curContext.Response.Charset = "";

                // 导出excel文件
                strWriter = new System.IO.StringWriter();
                htmlWriter = new System.Web.UI.HtmlTextWriter(strWriter);

                // 为了解决dgData中可能进行了分页的情况,需要重新定义一个无分页的DataGrid
                dgExport = new System.Web.UI.WebControls.DataGrid();
                dgExport.DataSource = dtData.DefaultView;
                dgExport.AllowPaging = false;
                dgExport.DataBind();

                // 返回客户端
                dgExport.RenderControl(htmlWriter);
                curContext.Response.Write(strWriter.ToString());
                curContext.Response.End();
            }
        }
开发者ID:samjustin8231,项目名称:LandAndResourcesBureauSys,代码行数:40,代码来源:Util.cs

示例12: ToXml

 public static String ToXml(this object source )
 {
     var stringwriter = new System.IO.StringWriter();
     var serializer = new XmlSerializer(typeof(RulePack));
     serializer.Serialize(stringwriter, source);
     return stringwriter.ToString();
 }
开发者ID:prashantkar,项目名称:Fortify_RulePack_Creation,代码行数:7,代码来源:ExtensionMethods.cs

示例13: Button1_Click

        protected void Button1_Click(object sender, EventArgs e)
        {
            GridView1.AllowPaging = false;

            //GridView1.DataSource = AccessDataSource1;

            GridView1.DataBind();

            DateTime dt = DateTime.Now;

            string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Second.ToString();

            Response.Clear();

            Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode("用户列表" + filename, System.Text.Encoding.UTF8) + ".xls");//导出文件命名

            Response.ContentEncoding = System.Text.Encoding.UTF8;//如果设置为"GB2312"则中文字符可能会乱码

            Response.ContentType = "application/ms-excel";

            System.IO.StringWriter oStringWriter = new System.IO.StringWriter();

            System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);

            Panel1.RenderControl(oHtmlTextWriter);

            Response.Write(oStringWriter.ToString());

            Response.Flush();

            Response.End();
        }
开发者ID:Rick1206,项目名称:innisfree,代码行数:32,代码来源:userlist.aspx.cs

示例14: CreateHtmlReport

 public string CreateHtmlReport()
 {
     var stringWriter = new System.IO.StringWriter();
     var indentedWriter = new IndentedTextWriter(stringWriter);
     CreateHtmlReport(indentedWriter);
     return stringWriter.ToString();
 }
开发者ID:NathanTeeuwen,项目名称:Dominulator,代码行数:7,代码来源:HtmlReportGenerator.cs

示例15: WritingTriGActual

        private void WritingTriGActual()
        {
            Graph g = new Graph();
            g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            g.BaseUri = null;
            TripleStore store = new TripleStore();
            store.Add(g);

            TriGWriter writer = new TriGWriter();
            System.IO.StringWriter strWriter = new System.IO.StringWriter();
            writer.Save(store, new TextWriterParams(strWriter));

            Console.WriteLine(strWriter.ToString());

            Assert.IsFalse(strWriter.ToString().Equals(String.Empty));
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:16,代码来源:TriGWriterTests.cs


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