本文整理汇总了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);
}
}
示例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);
}
}
示例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 ();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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());
});
}
示例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();
}
示例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();
}
}
示例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)
{
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例14: CreateHtmlReport
public string CreateHtmlReport()
{
var stringWriter = new System.IO.StringWriter();
var indentedWriter = new IndentedTextWriter(stringWriter);
CreateHtmlReport(indentedWriter);
return stringWriter.ToString();
}
示例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));
}