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


C# StringWriter.Dispose方法代码示例

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


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

示例1: FormatReturn

    public static string FormatReturn(int _flag, string _result)
    {
        string result;
        using (DataTable dt = new DataTable("table"))
        {
            dt.Columns.Add("flag");
            dt.Columns.Add("result");
            dt.Rows.Add(_flag, _result);
            StringWriter sw = new StringWriter();
            dt.WriteXml(sw);
            result = sw.ToString();
            sw.Dispose();
        }

        return result;
    }
开发者ID:kingpauloaquino,项目名称:CERP-WS,代码行数:16,代码来源:Functions.cs

示例2: getHTML

 private string getHTML(Panel Pnl)
 {
     StringBuilder sb = new StringBuilder();
     StringWriter textwriter = new StringWriter(sb);
     HtmlTextWriter htmlwriter = new HtmlTextWriter(textwriter);
     Pnl.RenderControl(htmlwriter);
     htmlwriter.Flush();
     textwriter.Flush();
     htmlwriter.Dispose();
     textwriter.Dispose();
     return sb.ToString();
 }
开发者ID:srisai339,项目名称:LoveJourney_Working,代码行数:12,代码来源:frmInternationalAvailablity.aspx.cs

示例3: GetXml

    public string GetXml(bool acceptDefaults, Dictionary<string, string> dict)
    {
        dict = (dict == null) ? new Dictionary<string, string>() : dict;

        //setting the HxFrom
        HxFrom.Text = ddlHxFrom.SelectedValue == "" ? tbHxOther.Text : ddlHxFrom.SelectedValue;

        StringWriter stringWriter = new StringWriter();
        XmlWriterSettings settings = new XmlWriterSettings();
        settings.CheckCharacters = false;
        XmlWriter xmlWriter = XmlWriter.Create(stringWriter, settings);
        //XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
        
        //xmlWriter.WriteStartDocument();
        xmlWriter.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"");
        xmlWriter.WriteStartElement("patient");

        foreach (Control ctrl in pageControls)
        {
            string customColourType = "0";
            if (ctrl.GetType().Name == "TextBox" || ctrl.GetType().Name == "DropDownList")
            {
                if (acceptDefaults || ColourType.ContainsKey(ctrl.ID))
                    customColourType = "0";
                else
                    customColourType = ((WebControl)ctrl).Attributes["CustomColourType"];
            }

            switch (ctrl.GetType().Name)
            {
                case "TextBox":
                    TextBox tb = (TextBox)ctrl;
                    xmlWriter.WriteStartElement(ctrl.ID);
                    if (dict.ContainsKey(ctrl.ID) && dict[ctrl.ID] != tb.Text.Trim())
                        customColourType = "2";
                    xmlWriter.WriteAttributeString("CustomColourType", customColourType);
                    tb.Attributes["CustomColourType"] = customColourType;
                    xmlWriter.WriteCData(tb.Text.Trim().Replace("'", "''"));
                    xmlWriter.WriteEndElement();
                    break;
                case "HiddenField":
                    xmlWriter.WriteStartElement(ctrl.ID);
                    xmlWriter.WriteCData(((HiddenField)ctrl).Value);
                    xmlWriter.WriteEndElement();
                    break;
                case "DropDownList":
                    DropDownList ddl = (DropDownList)ctrl;
                    xmlWriter.WriteStartElement(ctrl.ID);
                    if (dict.ContainsKey(ctrl.ID) && dict[ctrl.ID] != ddl.SelectedValue.Trim())
                        customColourType = "2";
                    xmlWriter.WriteAttributeString("CustomColourType", customColourType);
                    ddl.Attributes["CustomColourType"] = customColourType;
                    xmlWriter.WriteCData(ddl.SelectedValue.Trim().Replace("'", "''"));
                    xmlWriter.WriteEndElement();
                    break;
                case "CheckBox":
                    xmlWriter.WriteStartElement(ctrl.ID);
                    xmlWriter.WriteString(((CheckBox)ctrl).Checked.ToString());
                    xmlWriter.WriteEndElement();
                    break;
            }
        }

        xmlWriter.WriteEndElement();
        //xmlWriter.WriteEndDocument();
        xmlWriter.Flush();
        xmlWriter.Close();
        stringWriter.Flush();
        string xml = stringWriter.ToString();
        stringWriter.Dispose();
        return xml;
    }
开发者ID:prasannapattam,项目名称:ExamPatient,代码行数:72,代码来源:ExamPatient.aspx.cs

示例4: Export_with_XSLT_Windows

		// Function  : Export_with_XSLT_Windows 
		// Arguments : dsExport, sHeaders, sFileds, FormatType, FileName
		// Purpose   : Exports dataset into CSV / Excel format

		private void Export_with_XSLT_Windows(DataSet dsExport, string[] sHeaders, string[] sFileds, ExportFormat FormatType, string FileName)
		{
			
			try
			{				
				// XSLT to use for transforming this dataset.						
				MemoryStream stream = new MemoryStream( );
				XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8);				
				CreateStylesheet(writer, sHeaders, sFileds, FormatType);
				writer.Flush( ); 
				stream.Seek( 0, SeekOrigin.Begin);
                XmlDocument xsl = new XmlDocument();
                xsl.Load(stream);

                //XslTransform xslTran = new XslTransform();				
                //xslTran.Load(new XmlTextReader(stream), null, null);				
                //System.IO.StringWriter  sw = new System.IO.StringWriter();			
                //xslTran.Transform(xmlDoc, null, sw, null);

                XmlDataDocument xmlDoc = new XmlDataDocument(dsExport);

                StringWriter sw = new StringWriter();
                XmlTextWriter xtw = new XmlTextWriter(sw);
                XslCompiledTransform t = new XslCompiledTransform();
                t.Load((IXPathNavigable)xsl, null, null);
                t.Transform((IXPathNavigable)xmlDoc, xtw);

                //Writeout the Content				
                File.WriteAllText(FileName, sw.ToString());
                sw.Close();
                xtw.Close();
                writer.Close();
                stream.Close();
                sw.Dispose();
                stream.Dispose();
            }			
			catch(Exception Ex)
			{
				throw Ex;
			}
		}		
开发者ID:ViniciusConsultor,项目名称:sqlschematool,代码行数:45,代码来源:ExportData.cs

示例5: Export_with_XSLT_Web

		// Function  : Export_with_XSLT_Web 
		// Arguments : dsExport, sHeaders, sFileds, FormatType, FileName
		// Purpose   : Exports dataset into CSV / Excel format

		private void Export_with_XSLT_Web(DataSet dsExport, string[] sHeaders, string[] sFileds, ExportFormat FormatType, string FileName)
		{
			try
			{				
				// Appending Headers
				response.Clear();
				response.Buffer= true;
				
				if(FormatType == ExportFormat.CSV)
				{
					response.ContentType = "text/csv";
					response.AppendHeader("content-disposition", "attachment; filename=" + FileName);
				}		
				else
				{
					response.ContentType = "application/vnd.ms-excel";
					response.AppendHeader("content-disposition", "attachment; filename=" + FileName);
				}

				// XSLT to use for transforming this dataset.						
				MemoryStream stream = new MemoryStream( );
				XmlTextWriter writer = new XmlTextWriter(stream, Encoding.Default);
				CreateStylesheet(writer, sHeaders, sFileds, FormatType);
				writer.Flush( ); 
				stream.Seek( 0, SeekOrigin.Begin);
                XmlDocument xsl = new XmlDocument();
                xsl.Load(stream);

                //XslTransform xslTran = new XslTransform();				
                //xslTran.Load(new XmlTextReader(stream), null, null);				
                //System.IO.StringWriter  sw = new System.IO.StringWriter();			
                //xslTran.Transform(xmlDoc, null, sw, null);

                XmlDataDocument xmlDoc = new XmlDataDocument(dsExport);

                StringWriter sw = new StringWriter();
                XmlTextWriter xtw = new XmlTextWriter(sw);
                XslCompiledTransform t = new XslCompiledTransform();
                t.Load((IXPathNavigable)xsl, null, null);
                t.Transform((IXPathNavigable)xmlDoc, xtw);
					
				//Writeout the Content				
				response.Write(sw.ToString());			
				sw.Close();
                xtw.Close();
				writer.Close();
				stream.Close();			
				response.End();
                sw.Dispose();
                stream.Dispose();
			}
			catch(ThreadAbortException Ex)
			{
				string ErrMsg = Ex.Message;
			}
			catch(Exception Ex)
			{
				throw Ex;
			}
		}		
开发者ID:ViniciusConsultor,项目名称:sqlschematool,代码行数:64,代码来源:ExportData.cs


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