本文整理汇总了C#中System.IO.StringWriter.str方法的典型用法代码示例。如果您正苦于以下问题:C# StringWriter.str方法的具体用法?C# StringWriter.str怎么用?C# StringWriter.str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StringWriter
的用法示例。
在下文中一共展示了StringWriter.str方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: htmlToXml
public static string htmlToXml(this string htmlCode, bool xmlFormat)
{
try
{
var stringWriter = new StringWriter();
var xmlWriter = XmlWriter.Create(stringWriter);
xmlWriter.Flush();
var htmlDocument = htmlCode.htmlDocument();
htmlDocument.Save(xmlWriter);
if (xmlFormat)
return stringWriter.str().xmlFormat();
return stringWriter.str();
}
catch (Exception ex)
{
ex.log("[string.htmlToXml]");
return ex.Message;
}
}
示例2: xmlFormat
public static string xmlFormat(this string xml, int indentation, char indentChar)
{
XmlDocument doc = new XmlDocument();
doc.Load(xml.xmlReader());
var stringWriter = new StringWriter();
var xmlWriter = new XmlTextWriter(stringWriter);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.Indentation = indentation;
xmlWriter.IndentChar = indentChar;
xmlWriter.field("encoding", new UTF8Encoding()); //DC: is there another to set this
doc.Save(xmlWriter);
return stringWriter.str();
}
示例3: ProcessRequest
public string ProcessRequest(string page)
{
O2Gui.open<System.Windows.Forms.Panel>("Util - LogViewer", 400,140).add_LogViewer();
"Current Directory: {0}".info(Environment.CurrentDirectory);
var o2Timer = new O2Timer("ProcessRequest for file: {0}".info(page)).start();
Page = page ?? Page;
var stringWriter = new StringWriter();
simpleWorkerRequest = new SimpleWorkerRequest(Page, string.Empty, stringWriter);
//openScript();
//"Good Morning".execute_InScriptEditor_InSeparateAppDomain();
"processing request for: {0}".info(Page);
HttpRuntime.ProcessRequest(simpleWorkerRequest);
var Html = stringWriter.str();
o2Timer.stop();
return Html;
}
示例4: xmlString
public static string xmlString(this XmlDocument xmlDocument)
{
var stringBuilder = new StringBuilder();
var stringWriter = new StringWriter(stringBuilder);
xmlDocument.Save(stringWriter);
return stringWriter.str();
}
示例5: xsl_Transform
public static string xsl_Transform(this string xmlContent, string xstlFile)
{
try
{
var xslTransform = new XslCompiledTransform();
xslTransform.Load(xstlFile);
var xmlReader = new XmlTextReader(new StringReader(xmlContent));
var xpathNavigator = new XPathDocument(xmlReader);
var stringWriter = new StringWriter();
xslTransform.Transform(xpathNavigator, new XsltArgumentList(), stringWriter);
return stringWriter.str();
}
catch (Exception ex)
{
ex.log("[in xsl_Transform]");
return "";
}
}
示例6: handleAction_Xsl
private bool handleAction_Xsl(string data, string xsltToUse)
{
//if (this.tmWebServices.tmAuthentication.sessionID. UserRole.ReadArticles
var xstlFile = context.Server.MapPath("\\xslt\\" + xsltToUse);
if (xstlFile.fileExists())
{
var guid = tmWebServices.getGuidForMapping(data);
if (guid != Guid.Empty)
{
var xmlContent = tmWebServices.XmlDatabase_GetGuidanceItemXml(guid);
//.add_Xslt(xsltToUse);
if (xmlContent.valid())
{
//var xslTransform = new System.Xml.Xsl.XslTransform();
var xslTransform = new System.Xml.Xsl.XslCompiledTransform();
xslTransform.Load(xstlFile);
var xmlReader = new System.Xml.XmlTextReader(new StringReader(xmlContent));
var xpathNavigator = new System.Xml.XPath.XPathDocument(xmlReader);
var stringWriter = new StringWriter();
xslTransform.Transform(xpathNavigator, new System.Xml.Xsl.XsltArgumentList(), stringWriter);
context.Response.ContentType = "text/html";
context.Response.Write(stringWriter.str());
return true;
}
return false;
}
return transfer_ArticleViewer();
}
return false;
}
示例7: handleAction_Xsl
public void handleAction_Xsl(string data, string xsltToUse)
{
//if (this.TmWebServices.tmAuthentication.sessionID. UserRole.ReadArticles
var xstlFile = context.Server.MapPath("\\xslt\\" + xsltToUse);
if (xstlFile.fileExists())
{
var guid = tmWebServices.getGuidForMapping(data);
if (guid != Guid.Empty)
{
var xmlContent = tmWebServices.XmlDatabase_GetGuidanceItemXml(guid);
//.add_Xslt(xsltToUse);
if (xmlContent.valid())
{
//var xslTransform = new System.Xml.Xsl.XslTransform();
var xslTransform = new System.Xml.Xsl.XslCompiledTransform();
xslTransform.Load(xstlFile);
var xmlReader = new System.Xml.XmlTextReader(new StringReader(xmlContent));
var xpathNavigator = new System.Xml.XPath.XPathDocument(xmlReader);
var stringWriter = new StringWriter();
xslTransform.Transform(xpathNavigator, new System.Xml.Xsl.XsltArgumentList(), stringWriter);
context.Response.ContentType = "text/html";
context.Response.Write(stringWriter.str());
var article = tmWebServices.GetGuidanceItemById(guid);
switch(xsltToUse)
{
case "Notepad_Edit.xslt":
tmWebServices.RBAC_Demand_EditArticles(); // will trigger an Security exception if the user if not authorized
tmWebServices.logUserActivity("Edit Article (Notepad)", "{0} ({1})".format(article.Metadata.Title, guid));
break;
case "TeamMentor_Article.xslt":
tmWebServices.logUserActivity("View Article (xslt)", "{0} ({1})".format(article.Metadata.Title, guid));
break;
case "JsCreole_Article.xslt":
tmWebServices.logUserActivity("View Article (wiki)", "{0} ({1})".format(article.Metadata.Title, guid));
break;
default:
tmWebServices.logUserActivity("View Article ({0})", "{1} ({2})".format(xsltToUse, data,xsltToUse));
break;
}
endResponse();
}
}
else
transfer_Request("articleViewer"); // will trigger exception
}
}