本文整理汇总了C#中System.Web.UI.HtmlTextWriter.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.Flush方法的具体用法?C# HtmlTextWriter.Flush怎么用?C# HtmlTextWriter.Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.HtmlTextWriter
的用法示例。
在下文中一共展示了HtmlTextWriter.Flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
public byte[] Generate(Models.WordList wordList)
{
MemoryStream mem = new MemoryStream();
Encoding encoding = new UTF8Encoding(false);
using (StreamWriter streamWriter = new StreamWriter(mem, encoding))
{
using (HtmlTextWriter writer = new HtmlTextWriter(streamWriter))
{
writer.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
writer.WriteLine("<!DOCTYPE html>");
writer.WriteLine("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
writer.WriteLine("<head>");
WriteStyleSection(writer);
writer.WriteLine("</head>");
writer.WriteLine("<body>");
foreach (WordForm wordForm in wordList.GetAllForms().OrderBy(wf => wf.Title))
{
WriteWordForm(writer, wordForm);
}
writer.WriteLine("</body>");
writer.WriteLine("</html>");
writer.Flush();
}
}
return mem.ToArray();
}
示例2: Render
public static string Render(RenderFunc func)
{
string content = string.Empty;
using (MemoryStream ms = new MemoryStream())
{
using (HtmlTextWriter htmlWriter = new HtmlTextWriter(new StreamWriter(ms)))
{
func(htmlWriter);
htmlWriter.Flush();
}
using (StreamReader rdr = new StreamReader(ms))
{
rdr.BaseStream.Position = 0;
content = rdr.ReadToEnd();
}
}
ITemplateEngine te = ServiceLocator.Instance.Resolve<ITemplateEngine>();
using (StringWriter sw = new StringWriter())
{
te.Process(JContext.Current.ViewData, string.Empty, sw, content);
return sw.GetStringBuilder().ToString();
}
}
示例3: GetDesignTimeHtml
/// <summary>
/// 获取设计时HTML
/// </summary>
/// <returns></returns>
public override string GetDesignTimeHtml()
{
try
{
TabControl oTabStrip = ((TabControl)Component);
if (oTabStrip.Items == null || oTabStrip.Items.Count == 0)
{
return GetEmptyDesignTimeHtml();
}
System.Text.StringBuilder oSB = new System.Text.StringBuilder();
StringWriter oStringWriter = new StringWriter(oSB);
HtmlTextWriter oWriter = new HtmlTextWriter(oStringWriter);
oTabStrip.RenderDownLevelContent(oWriter);
oWriter.Flush();
oStringWriter.Flush();
return oSB.ToString();
}
catch (Exception ex)
{
return CreatePlaceHolderDesignTimeHtml("生成设计时代码错误:\n\n" + ex.ToString());
}
}
示例4: ProcessRequest
public new void ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, string operationName)
{
EndpointHost.Config.AssertFeatures(Feature.Metadata);
var operations = EndpointHost.ServiceOperations;
if (httpReq.QueryString["xsd"] != null)
{
var xsdNo = Convert.ToInt32(httpReq.QueryString["xsd"]);
var schemaSet = XsdUtils.GetXmlSchemaSet(operations.AllOperations.Types);
var schemas = schemaSet.Schemas();
var i = 0;
if (xsdNo >= schemas.Count)
{
throw new ArgumentOutOfRangeException("xsd");
}
httpRes.ContentType = "text/xml";
foreach (XmlSchema schema in schemaSet.Schemas())
{
if (xsdNo != i++) continue;
schema.Write(httpRes.Output);
break;
}
return;
}
var writer = new HtmlTextWriter(httpRes.Output);
httpRes.ContentType = "text/html";
ProcessOperations(writer, httpReq);
writer.Flush();
}
示例5: GetDesignTimeHtml
/// <summary>
/// 获得设计时的HTML
/// </summary>
/// <returns>字符串</returns>
public override string GetDesignTimeHtml()
{
try
{
string output = "";
Control oControl = ((Control)Component);
StringBuilder strB = new StringBuilder(1024);
using (StringWriter sw = new StringWriter(strB))
{
HtmlTextWriter oWriter = new HtmlTextWriter(sw);
oControl.RenderControl(oWriter);
oWriter.Flush();
sw.Flush();
output = strB.ToString();
if (output == null ||output==String.Empty)
{
return GetEmptyDesignTimeHtml();
}
return output ;
}
}
catch (Exception ex)
{
return CreatePlaceHolderDesignTimeHtml(Resources.DeluxeWebResource.DesignerTimeErrorMessage + ex.ToString());
}
}
示例6: GetHtml
public static string GetHtml(HtmlGenericControl control)
{
StringBuilder s = new StringBuilder();
HtmlTextWriter tw = new HtmlTextWriter(new StringWriter(s));
control.RenderControl(tw);
tw.Flush();
return s.ToString();
}
示例7: Render
protected override void Render(HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
HtmlTextWriter tempWriter = new HtmlTextWriter(new StringWriter(sb));
base.Render(tempWriter);
tempWriter.Flush();
tempWriter.Close();
writer.Write(MyCompany.Data.Localizer.Replace("Pages", Path.GetFileName(Request.PhysicalPath), sb.ToString()));
}
示例8: Render
protected override void Render(HtmlTextWriter writer)
{
string layout = string.Empty;
// remove contents before render it
foreach (Control ctrl in ctrls)
{
Controls.Remove(ctrl);
}
using (MemoryStream ms = new MemoryStream())
{
using (HtmlTextWriter htmlWriter = new HtmlTextWriter(new StreamWriter(ms)))
{
base.Render(htmlWriter);
htmlWriter.Flush();
}
using (StreamReader rdr = new StreamReader(ms))
{
rdr.BaseStream.Position = 0;
layout = rdr.ReadToEnd();
}
}
foreach (Control ctrl in ctrls)
{
string tag = "{" + ctrl.ID + "}";
if (layout.IndexOf(tag) == -1)
throw new ArgumentException(string.Format("{0} not found!", tag));
string content = string.Empty;
using (MemoryStream ms = new MemoryStream())
{
using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new StreamWriter(ms)))
{
ctrl.RenderControl(htmlwriter);
htmlwriter.Flush();
}
using (StreamReader rdr = new StreamReader(ms))
{
rdr.BaseStream.Position = 0;
content = rdr.ReadToEnd();
}
}
layout = layout.Replace(tag, content);
}
writer.Write(layout);
}
示例9: RenderControl
public static string RenderControl(Control control)
{
using (var writer = new StringWriter())
using (var htmlWriter = new HtmlTextWriter(writer))
{
control.RenderControl(htmlWriter);
htmlWriter.Flush();
return writer.ToString();
}
}
示例10: Render
public string Render(string newLine)
{
StringWriter sw = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(sw, "");
writer.NewLine = newLine;
base.Render(writer);
writer.Flush();
writer.Close();
string result = sw.GetStringBuilder().ToString();
return result;
}
示例11: Compression
public void Compression(System.Web.UI.HtmlTextWriter writer)
{
StringWriter sr = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(sr);
base.Render(tw);
tw.Flush();
tw.Dispose();
StringBuilder sb = new StringBuilder(sr.ToString());
string outhtml = Regex.Replace(sb.ToString(), "\\r+\\n+\\s+", string.Empty);
writer.Write(outhtml);
sr.Dispose();
}
示例12: GetHtml
public string GetHtml()
{
// populate the control
this.PopulateControl();
StringWriter buffer = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(buffer);
this.RenderControl(writer);
writer.Flush();
return buffer.ToString().Trim();
}
示例13: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
StringBuilder renderedOutput = null;
StringWriter strWriter = null;
HtmlTextWriter tWriter = null;
try
{
renderedOutput = new StringBuilder();
strWriter = new StringWriter( renderedOutput );
tWriter = new HtmlTextWriter( strWriter );
view.RenderControl( tWriter );
tWriter.Flush();
strWriter.Flush();
Response.Write( renderedOutput.ToString() );
Response.Flush();
}
catch( Exception ex )
{
SendJson( new Framework.API.ReturnObject {
Error = true,
Message = "There was an error loading the requested page.",
Result = new {
Message = ex.Message,
Type = ex.GetType().FullName,
StackTrace = ex.StackTrace
}
} );
}
finally
{
if( tWriter != null )
{
tWriter.Close();
tWriter.Dispose();
tWriter = null;
}
if( strWriter != null )
{
strWriter.Close();
strWriter.Dispose();
strWriter = null;
}
}
Response.End();
}
示例14: CaptureViewOutput
public static string CaptureViewOutput(Controller controller, ViewResult view)
{
var builder = new StringBuilder();
using (var stringWriter = new StringWriter(builder))
{
using (var htmlTextWriter = new HtmlTextWriter(stringWriter))
{
var currentContext = controller.ControllerContext.HttpContext;
try
{
// get the Request and User objects from the current, unchanged context
var currentRequest = HttpContext.Current.ApplicationInstance.Context.Request;
var currentUser = HttpContext.Current.ApplicationInstance.Context.User;
// create our new HttpResponse object containing our HtmlTextWriter
var newResponse = new HttpResponse(htmlTextWriter);
// create a new HttpContext object using our new Response object and the existing Request and User objects
var newContext = new HttpContextWrapper(
new HttpContext(currentRequest, newResponse)
{
User = currentUser
});
// swap in our new HttpContext object - output from this controller is now going to our HtmlTextWriter object
controller.ControllerContext.HttpContext = newContext;
// Run the ViewResult
view.ExecuteResult(controller.ControllerContext);
// flush the output
newResponse.Flush();
htmlTextWriter.Flush();
stringWriter.Flush();
}
finally
{
// and no matter what happens, set the context back!
controller.ControllerContext.HttpContext = currentContext;
}
}
}
// our StringBuilder object now contains the output of the ViewResult object
return builder.ToString();
}
示例15: Render
protected override void Render( HtmlTextWriter writer )
{
using ( var memoryStream = new MemoryStream( ) ) {
using ( var streamWriter = new StreamWriter( memoryStream ) ) {
using ( var htmlTextWriter = new HtmlTextWriter( streamWriter ) ) {
base.Render( htmlTextWriter );
htmlTextWriter.Flush( );
memoryStream.Position = 0;
TextReader textReader = new StreamReader( memoryStream );
String output = textReader.ReadToEnd( );
String newOutput = RewriteOutput( output );
writer.Write( newOutput );
}
}
}
}