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


C# HtmlTextWriter.Flush方法代码示例

本文整理汇总了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();
        }
开发者ID:yu-kopylov,项目名称:cramtool,代码行数:31,代码来源:HtmlGenerator.cs

示例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();
            }
        }
开发者ID:Aliceljm1,项目名称:kiss-project.web,代码行数:29,代码来源:Util.cs

示例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());
            }
        }
开发者ID:yeyong,项目名称:manageserver,代码行数:30,代码来源:TabControlDesigner.cs

示例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();
        }
开发者ID:nigthwatch,项目名称:ServiceStack,代码行数:31,代码来源:BaseSoapMetadataHandler.cs

示例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());
            }
        }
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:31,代码来源:DesignerBase.cs

示例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();
 }
开发者ID:dblock,项目名称:sncore,代码行数:8,代码来源:HtmlGenericExtractor.cs

示例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()));
 }
开发者ID:mehedi09,项目名称:GridWork,代码行数:9,代码来源:PageBase.cs

示例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);
        }
开发者ID:Aliceljm1,项目名称:kiss-project.web,代码行数:55,代码来源:Layout.cs

示例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();
            }
        }
开发者ID:sigcms,项目名称:Seeger,代码行数:11,代码来源:ControlHelper.cs

示例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;
 }
开发者ID:spring-projects,项目名称:spring-net,代码行数:11,代码来源:TestPage.cs

示例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();
 }
开发者ID:ReinhardHsu,项目名称:devfw,代码行数:12,代码来源:Page.cs

示例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();
        }
开发者ID:ratnazone,项目名称:ratna,代码行数:13,代码来源:SnippetControl.cs

示例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();
        }
开发者ID:REMSLogic,项目名称:REMSLogic,代码行数:51,代码来源:Page.aspx.cs

示例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();
        }
开发者ID:GroM,项目名称:Shaver,代码行数:48,代码来源:ControllerHelper.cs

示例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 );
              }
            }
              }
        }
开发者ID:aliska76,项目名称:test,代码行数:17,代码来源:ExtendedViewMasterPage.cs


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