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


C# StringWriter.Flush方法代码示例

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


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

示例1: Transform

    public static string Transform(string xsltFile, string xml, XsltArgumentList xslArg)
    {
        string result = "";
        try {

        XslCompiledTransform xslt = new XslCompiledTransform();
        xslt.Load(xsltFile);
        // XmlWriterSettings.OmitXmlDeclaration

        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(new StringReader(xml));

        XmlWriterSettings settings = new XmlWriterSettings();
        settings.Indent = true;
        settings.OmitXmlDeclaration = true;
        settings.NewLineOnAttributes = true;

        using (StringWriter sw = new StringWriter()) {
        using (XmlWriter writer = XmlWriter.Create(sw, settings)) {
            xslt.Transform(xmlDoc, xslArg, writer);
        }
        sw.Flush();
        result = sw.ToString();
          }
        } catch (Exception ex) {
        Console.WriteLine(ex.ToString());
        }
        return result;
    }
开发者ID:xesrochers,项目名称:bijou,代码行数:29,代码来源:XmlUtils.cs

示例2: GenerateCode

    public static StringBuilder GenerateCode(CodeNamespace ns)
    {
        var codeProvider = new CSharpCodeProvider();
        var builder = new StringBuilder();
        var writer = new StringWriter(builder);

        codeProvider.GenerateCodeFromNamespace(ns, writer, new CodeGeneratorOptions());
        writer.Flush();
        return builder;
    }
开发者ID:scy0846,项目名称:Umbraco.CodeGen,代码行数:10,代码来源:CodeGenerationHelper.cs

示例3: GenerateCode

    public static StringBuilder GenerateCode(CodeNamespace ns)
    {
        var compileUnit = new CodeCompileUnit();
        var codeProvider = new CSharpCodeProvider();
        var builder = new StringBuilder();
        var writer = new StringWriter(builder);

        compileUnit.Namespaces.Add(ns);
        codeProvider.GenerateCodeFromCompileUnit(compileUnit, writer, new CodeGeneratorOptions());
        writer.Flush();
        return builder;
    }
开发者ID:jkarsrud,项目名称:Umbraco.CodeGen,代码行数:12,代码来源:CodeGenerationHelper.cs

示例4: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        string m = "<?xml version=\"1.0\"?>";
        m += "<address>";
        m += "<addressline1>" + "Veerannapet" + "</addressline1>";
        m += "<addressline2>" + "Veerannapet2" + "</addressline2>";
        m += "<city>" + "Mahabubnagar" + "</city>";
        m += "<postcode>" + "509001" + "</postcode>";
        m += "</address>";

        string result1 = m.Replace("<?xml version=\"1.0\"?>", "");

        XmlDocument docs = new XmlDocument();
        docs.LoadXml(result1);
        string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(docs);

        XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(json, "Report");

        XslCompiledTransform xsl = new XslCompiledTransform();
        StringWriter result = new StringWriter();

        xsl.Load(Server.MapPath("Focus.xslt"));

        XmlTextWriter tx = new XmlTextWriter(result);

        XmlDeclaration xmldecl;
        xmldecl = doc.CreateXmlDeclaration("1.0", null, null);

        XmlElement root = doc.DocumentElement;
        doc.InsertBefore(xmldecl, root);

        //string strs = doc.InnerXml.ToString();
        doc.WriteTo(tx);
        xsl.Transform(doc, null, tx);

        result.Close();
        result.Flush();

        string str = result.ToString();
        // ... And the result you'll send back will be usable in a report:
        Response.ContentType = "text/xml";
        Response.Write(str.ToString());

        Response.Flush();
        Response.Close();
    }
开发者ID:narayantalakanti,项目名称:RepliconCode,代码行数:46,代码来源:XmlTest.aspx.cs

示例5: Consume

    public void Consume(string contentFolder, string siteFolder, string filename, string ext)
    {
        string contentFile = contentFolder + "/" + filename;
        string templateFile = GetTemplateFilename(filename, ext);
        SiteFile = siteFolder + "/index.html";

        try {
                //XsltArgumentList xslArg = BuildXsltArgumentList();
        XslCompiledTransform xslt = new XslCompiledTransform();
        xslt.Load(templateFile);

        using (StringWriter sw = new StringWriter()) {
              using (XmlWriter writer = XmlWriter.Create(sw)) {
          	xslt.Transform(contentFile, XslArgs, writer);
              }
              sw.Flush();
              Content = sw.ToString();
            }
        } catch (Exception ex) {
            ReportError(templateFile, contentFile, ex);
        }
    }
开发者ID:xesrochers,项目名称:bijou,代码行数:22,代码来源:XmlProcessor.cs

示例6: 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

示例7: 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

示例8: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            // Define the Company Name, User Name and Password here
            string ck = ConfigurationSettings.AppSettings["ck"].ToString();// Enter Company name here
            string username = ConfigurationSettings.AppSettings["username"].ToString(); // Enter User Name here
            string pwd = ConfigurationSettings.AppSettings["pwd"].ToString(); // Enter Password here
            string un = ck + "\\" + username;
            string strFileName = "";
            string strFolderPath = "";
            string Report_Url = ConfigurationSettings.AppSettings["ReportUrl"].ToString();

            // Define the Web Service URLs that you would use
            string getallreports_url = Report_Url + ck + "/services/ReportService1.svc/GetAllReports";
            string generatereport_url = Report_Url + ck + "/services/ReportService1.svc/GenerateReport";
            string report_uri = string.Empty;

            string dt2 = DateTime.Now.ToString("yyyyMMdd-HHmmss.ff").Replace("/", "").Replace("-", "").Replace(" ", "").Replace(":", "");
            strFileName = "Report_" +  "_" + dt2 + ".xml";
            Cache["Filename"] = strFileName;
            strFolderPath = Server.MapPath(".") + "\\Temp\\" + strFileName;

            string json = @"
                          {
                            'glossary':
                            {
                              'title': 'example glossary',
                                'GlossDiv':
                                {
                                  'title': 'S',
                                  'GlossList':
                                  {
                                    'GlossEntry':
                                    {
                                      'ID': 'SGML',
                                      'ItemNumber': 2,
                                      'SortAs': 'SGML',
                                      'GlossTerm': 'Standard Generalized Markup Language',
                                      'Acronym': 'SGML',
                                      'Abbrev': 'ISO 8879:1986',
                                      'GlossSee': 'markup'
                                    }
                                  }
                                }
                            }
                          }

                          ";

            //string payload = (string)getallreports_response["d"]["payload"];

            // Now get xml from Factual's JSON response:
            XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(json, "root");

            // Convert the json-based XML according to what Newtonsoft will do,
            // to ADO-shaped XML, very generically :

            XslCompiledTransform xsl = new XslCompiledTransform();
            StringWriter result = new StringWriter();

            xsl.Load(Server.MapPath("Focus.xslt"));
            // I should be caching this, it will always be the same

            xsl.Transform(doc, null, result);

            File.WriteAllText(strFolderPath, result.ToString());
            result.Close();
            result.Flush();

            // ... And the result you'll send back will be usable in a report:
            Response.ContentType = "application/xml";
            Response.Write(result.ToString());
            //Response.Flush();
            Response.AppendHeader("Content-Disposition", "attachment; filename=Report.xml");
            Response.TransmitFile(Server.MapPath(".") + "\\Temp\\" + strFileName);
            Response.End();

        }
        catch (Exception exp)
        {
            Response.Write(exp.Message.ToString());
        }
    }
开发者ID:narayantalakanti,项目名称:RepliconCode,代码行数:84,代码来源:Replicon_Json.aspx.cs

示例9: EchoRequestHandler

	static byte [] EchoRequestHandler (Socket socket)
	{
		MemoryStream ms = new MemoryStream ();
		byte [] buffer = new byte [4096];
		int bytesReceived = socket.Receive (buffer);
		while (bytesReceived > 0) {
			ms.Write (buffer, 0, bytesReceived);
			if (socket.Available > 0) {
				bytesReceived = socket.Receive (buffer);
			} else {
				bytesReceived = 0;
			}
		}
		ms.Flush ();
		ms.Position = 0;

		string request = string.Empty;
		using (StreamReader sr = new StreamReader (ms, Encoding.UTF8)) {
			request = sr.ReadToEnd ();
		}

		StringWriter sw = new StringWriter ();
		sw.WriteLine ("HTTP/1.1 200 OK");
		sw.WriteLine ("Content-Type: text/xml");
		sw.WriteLine ("Content-Length: " + request.Length.ToString (CultureInfo.InvariantCulture));
		sw.WriteLine ();
		sw.Write (request);
		sw.Flush ();

		return Encoding.UTF8.GetBytes (sw.ToString ());
	}
开发者ID:mono,项目名称:gert,代码行数:31,代码来源:test.cs

示例10: SaveIbConfigSetting

    protected void SaveIbConfigSetting(object sender, EventArgs e)
    {
        if (Session["OriginalIbConfig"] != null)
        {
            TextWriter writer = null;
            try
            {
                string xmlSettingText = XMLResult.Value;
                string ibItemXmlSettingText = IbItemXMLResult.Value;
                string ibItemStyleXmlSettingText = IbItemStyleXMLResult.Value;
                IbConfig originalConfig = Session["OriginalIbConfig"] as IbConfig;

                UpdateIbItemInfo(originalConfig, ibItemXmlSettingText);
                UpdateIbItemStyleInfo(originalConfig, ibItemStyleXmlSettingText);

                IbConfig newConfig = IbConfig.ParseXml(originalConfig, new StringReader(xmlSettingText));
                newConfig.Order();

                writer = new StringWriter();
                newConfig.CreateSqlScript(writer);
                writer.Flush();
                long scriptId = -1;
                if (TheAdminServer.IBShopManager.SaveScript(writer.ToString(), out scriptId))
                {
                    LabelOpMsg.Text = StringDef.OperationSucceed;
                    FSEye.Security.LogSystem.TheInstance.WriteGMOperationLog(CurrentUser.Id,
                        (int)GMUtil.GMOperation.CreateIBShopScript,
                        scriptId.ToString(),
                        -1,
                        string.Format(StringDef.GMMessageIBShopScript, CurrentUser.RealName, StringDef.Create, scriptId.ToString()),
                        (int)GMUtil.GMOpTargetType.System);
                }
                else
                {
                    LabelOpMsg.Text = StringDef.OperationFail;
                    return;
                }
            }
            catch (Exception ex)
            {
                LabelOpMsg.Text = ex.Message;
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
            }
        }
    }
开发者ID:viticm,项目名称:pap2,代码行数:51,代码来源:IBShop.aspx.cs

示例11: Decode

                /// <summary>
                /// Decodes a Quoted-Printable string of any size into
                /// it's original text.
                /// </summary>
                /// <param name="encoded">
                /// The encoded string to decode.
                /// </param>
                /// <returns>The decoded string.</returns>
                /// <exception cref="ArgumentNullException">
                /// A string is passed in as a null reference.
                /// </exception>
                /// <remarks>
                /// Decodes a quoted-printable encoded string into a string
                /// of unencoded text of any size.
                /// </remarks>
                public static string Decode(string encoded)
                {
                    if (encoded == null)
                    {
                        throw (new ArgumentNullException());
                    }

                    string line;
                    StringWriter sw = new StringWriter();
                    StringReader sr = new StringReader(encoded);
                    try
                    {
                        line = sr.ReadLine();
                        while (line != null)
                        {
                            if (line.EndsWith("="))
                            {
                                sw.Write(HexDecoder(line.Substring(0, line.Length - 1)));
                            }
                            else
                            {
                                sw.WriteLine(HexDecoder(line));
                            }
                            sw.Flush();
                            line = sr.ReadLine();
                        }
                        return sw.ToString();
                    }
                    finally
                    {
                        sw.Close();
                        sr.Close();
                        sw = null;
                        sr = null;
                    }
                }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:51,代码来源:QuotedPrintable.cs

示例12: ConvertToXml

            public static string ConvertToXml(object toSerialize, Type objectType)
            {
                // create a string wrtiter to hold the xml string
                // the a xml writer with the proper settings.
                // use that writer to serialize the document.
                // use an  namespace to create a fully qualified odcument.
                StringWriter aWriter = new StringWriter();
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.OmitXmlDeclaration = true;
                settings.ConformanceLevel = ConformanceLevel.Document; // Fragment fails
                settings.Indent = false;
                settings.Encoding = System.Text.Encoding.UTF8;

                XmlWriter xWriter = XmlWriter.Create(aWriter, settings);

                new XmlSerializerNamespaces();
                XmlSerializerNamespaces myNamespaces = new XmlSerializerNamespaces();
                myNamespaces.Add("wtr", "http://www.cuahsi.org/waterML/1_1/");
                myNamespaces.Add("xsd", "http://www.w3.org/2001/XMLSchema");
                myNamespaces.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
                myNamespaces.Add("gml", "http://www.opengis.net/gml");
                myNamespaces.Add("xlink", "http://www.w3.org/1999/xlink");
                myNamespaces.Add("xml", "http://www.w3.org/XML/1998/namespace");

                XmlSerializer aSerializer = new XmlSerializer(objectType);
                //aSerialize(xWriter, toSerialize);
                aSerializer.Serialize(xWriter, toSerialize, myNamespaces);
                string xml = aWriter.ToString();
                aWriter.Flush();
                aWriter.Close();
                return xml;
            }
开发者ID:CUAHSI,项目名称:CUAHSI-GenericWOF_vs2013,代码行数:32,代码来源:WSUtils.cs

示例13: GenerateCode

 private static string GenerateCode(string expression)
 {
     var source = new StringBuilder();
     var sw = new StringWriter(source);
     var options = new CodeGeneratorOptions();
     var myNamespace = new CodeNamespace("ExpressionEvaluator");
     myNamespace.Imports.Add(new CodeNamespaceImport("System"));
     var classDeclaration = new CodeTypeDeclaration { IsClass = true, Name = "Calculator", Attributes = MemberAttributes.Public };
     var myMethod = new CodeMemberMethod { Name = "Calculate", ReturnType = new CodeTypeReference(typeof(double)), Attributes = MemberAttributes.Public };
     myMethod.Statements.Add(new CodeMethodReturnStatement(new CodeSnippetExpression(expression)));
     classDeclaration.Members.Add(myMethod);
     myNamespace.Types.Add(classDeclaration);
     provider.GenerateCodeFromNamespace(myNamespace, sw, options);
     sw.Flush();
     sw.Close();
     return source.ToString();
 }
开发者ID:ATouhou,项目名称:QuranCode,代码行数:17,代码来源:Calculator.cs

示例14: lnk_Xml_Report_Click


//.........这里部分代码省略.........
        string data_getallreports = string.Empty;

        var jsondata_getallreports = Newtonsoft.Json.JsonConvert.SerializeObject(data_getallreports);
        byte[] byteArray_getallreports = Encoding.UTF8.GetBytes(jsondata_getallreports);

        // Make the HTTP request using the function "callservice"
        var getallreports_response = callservice(un, pwd, getallreports_url, jsondata_getallreports, byteArray_getallreports);

        jsonText = getallreports_response.ToString();

        //Function to get the Report URI of the Report that you want to pull up
        foreach (var item in getallreports_response["d"])
        {
            if ((string)item["displayText"] == Report_name)
            {
                report_uri = (string)item["uri"];
            }
        }

        if (report_uri == string.Empty)
        {
            Console.WriteLine("No report exists in the Replicon Instance with the report name " + Report_name);
            Console.ReadKey();
            return;
        }

        // Create the JSON Object to pass with the HTTP request for GenerateReport
        dynamic data_generatereport = new ExpandoObject();
        data_generatereport.reportUri = report_uri;
        data_generatereport.filterValues = new string[0];
        //data_generatereport.outputFormatUri = "urn:replicon:report-output-format-option:msxml";

        /*
        // The JSON Object to be passed along with the HTTP Header can be also created in the following way
        // The JSON Object creation with DYNAMIC keyword can be used when the JSON Object will increase in size dynamically (e.g. using arrays)

        string data_generatereport = "{\"reportUri\":null,\"filterValues\":[],\"outputFormatUri\":null}";
        var jObject_GetData = Newtonsoft.Json.Linq.JObject.Parse(data_generatereport);
        data_generatereport["reportUri"] = report_uri;
        data_generatereport["outputFormatUri"] = "urn:replicon:report-output-format-option:msxml";
         */

        // Convert the Object created above to JSON and calculate the Content length
        var jsondata_generatereport = Newtonsoft.Json.JsonConvert.SerializeObject(data_generatereport);
        byte[] byteArray_generatereport = Encoding.UTF8.GetBytes(jsondata_generatereport);

        // Make the HTTP request using the function "callservice"
        var generatereport_response = callservice(un, pwd, generatereport_url, jsondata_generatereport, byteArray_generatereport);

        string payload = (string)generatereport_response["d"]["payload"];

        XmlDocument docs = new XmlDocument();
        docs.LoadXml(payload);
        string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(docs);

        DwnReport.Visible = true;

        //string payload = (string)getallreports_response["d"]["payload"];

        //File.WriteAllText(strFolderPath, jsonText);

        // Now get xml from Factual's JSON response:
        XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(payload, "Report");

        // Convert the json-based XML according to what Newtonsoft will do,
        // to ADO-shaped XML, very generically :

        XslCompiledTransform xsl = new XslCompiledTransform();
        StringWriter result = new StringWriter();

        xsl.Load(Server.MapPath("Focus.xslt"));

        XmlTextWriter tx = new XmlTextWriter(result);

        XmlDeclaration xmldecl;
        xmldecl = doc.CreateXmlDeclaration("1.0", null, null);

        XmlElement root = doc.DocumentElement;
        doc.InsertBefore(xmldecl, root);

        doc.WriteTo(tx);
        xsl.Transform(doc, null, tx);

        File.WriteAllText(strFolderPath, result.ToString());
        result.Close();
        result.Flush();

        // ... And the result you'll send back will be usable in a report:
        Response.ContentType = "text/xml";
        Response.Charset = "UTF-8";
        Response.ContentEncoding = Encoding.UTF8;
        //Response.Write(result.ToString());

        Response.AppendHeader("Content-Disposition", "attachment; filename=" + strFileName);
        Response.TransmitFile(Server.MapPath(".") + "\\Temp\\" + strFileName);
        Response.Flush();
        Response.Close();

        //strFolderPath = Server.MapPath(".") + "\\Temp\\" + strFileName;
    }
开发者ID:narayantalakanti,项目名称:RepliconCode,代码行数:101,代码来源:RepliconForm.aspx.cs


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