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


C# System.Xml.XmlTextWriter.Flush方法代码示例

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


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

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int report_uid;
            int new_state;

            if (int.TryParse(Request.QueryString["report_uid"], out report_uid) == false)
            {
                return;
            }

            if (int.TryParse(Request.QueryString["state"], out new_state) == false)
                new_state = 1;

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Outputs");

                DB.UpdateReportState(report_uid, new_state);

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
开发者ID:NtreevSoft,项目名称:Crashweb,代码行数:30,代码来源:UpdateReportState.aspx.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();

                writer.WriteStartElement("Project");
                writer.WriteStartElement("Items");

                Dictionary<int, sProject> projectList;
                DB.LoadProject(out projectList);

                foreach (KeyValuePair<int, sProject> item in projectList)
                {
                    writer.WriteStartElement("Item");
                    writer.WriteAttributeString("uid", item.Key.ToString());
                    writer.WriteAttributeString("name", item.Value.name);
                    writer.WriteEndElement();
                }

                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
开发者ID:NtreevSoft,项目名称:Crashweb,代码行数:29,代码来源:ProjectList.aspx.cs

示例3: Create

        /// <summary>
        /// Construct an StreamContent from a provided populated OFX object
        /// </summary>
        /// <param name="ofxObject">A populated OFX message with request or response data</param>
        /// <returns>Created StreamContent ready to send with HttpClient.Post</returns>
        public static StreamContent Create(Protocol.OFX ofxObject)
        {
            // Serialized data will be written to a MemoryStream
            var memoryStream = new System.IO.MemoryStream();

            // XMLWriter will be used to encode the data using UTF8Encoding without a Byte Order Marker (BOM)
            var xmlWriter = new System.Xml.XmlTextWriter(memoryStream, new System.Text.UTF8Encoding(false));

            // Write xml processing instruction
            xmlWriter.WriteStartDocument();
            // Our OFX protocol uses a version 2.0.0 header with 2.1.1 protocol body
            xmlWriter.WriteProcessingInstruction("OFX", "OFXHEADER=\"200\" VERSION=\"211\" SECURITY=\"NONE\" OLDFILEUID=\"NONE\" NEWFILEUID=\"NONE\"");

            // Don't include namespaces in the root element
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
            ns.Add("", "");

            // Generate XML to the stream
            m_serializer.Serialize(xmlWriter, ofxObject, ns);

            // Flush writer to stream
            xmlWriter.Flush();

            // Position the stream back to the start for reading
            memoryStream.Position = 0;

            // Wrap in our HttpContent-derived class to provide headers and other HTTP encoding information
            return new StreamContent(memoryStream);
        }
开发者ID:rhadman,项目名称:SoDotCash,代码行数:34,代码来源:StreamContent.cs

示例4: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int callstack_uid;

            if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false)
                callstack_uid = 1;

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Callstack");

                DB.LoadCallstack(callstack_uid,
                    delegate(int depth, string funcname, string fileline)
                    {
                        writer.WriteStartElement("Singlestep");
                        writer.WriteAttributeString("depth", depth.ToString());
                        this.WriteCData(writer, "Funcname", funcname);
                        this.WriteCData(writer, "Fileline", fileline);
                        writer.WriteEndElement();
                    }
                );

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
开发者ID:NtreevSoft,项目名称:Crashweb,代码行数:33,代码来源:CallstackView.aspx.cs

示例5: IsolatedStorage_Read_and_Write_Sample

        public static void IsolatedStorage_Read_and_Write_Sample()
        {
            string fileName = @"SelfWindow.xml";

            IsolatedStorageFile storFile = IsolatedStorageFile.GetUserStoreForDomain();
            IsolatedStorageFileStream storStream = new IsolatedStorageFileStream(fileName, FileMode.Create, FileAccess.Write);
            System.Xml.XmlWriter writer = new System.Xml.XmlTextWriter(storStream, Encoding.UTF8);
            writer.WriteStartDocument();

            writer.WriteStartElement("Settings");

            writer.WriteStartElement("UserID");
            writer.WriteValue(42);
            writer.WriteEndElement();
            writer.WriteStartElement("UserName");
            writer.WriteValue("kingwl");
            writer.WriteEndElement();

            writer.WriteEndElement();

            writer.Flush();
            writer.Close();
            storStream.Close();

            string[] userFiles = storFile.GetFileNames();

            foreach(var userFile in userFiles)
            {
                if(userFile == fileName)
                {
                    var storFileStreamnew =  new IsolatedStorageFileStream(fileName,FileMode.Open,FileAccess.Read);
                    StreamReader storReader = new StreamReader(storFileStreamnew);
                    System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(storReader);

                    int UserID = 0;
                    string UserName = null;

                    while(reader.Read())
                    {
                        switch(reader.Name)
                        {
                            case "UserID":
                                UserID = int.Parse(reader.ReadString());
                                break;
                            case "UserName":
                                UserName = reader.ReadString();
                                break;
                            default:
                                break;
                        }
                    }

                    Console.WriteLine("{0} {1}", UserID, UserName);

                    storFileStreamnew.Close();
                }
            }
            storFile.Close();
        }
开发者ID:xxy1991,项目名称:cozy,代码行数:59,代码来源:D8IsolatedStorageReadAndWrite.cs

示例6: WriteTo

 public void WriteTo(object entity, IHttpEntity response, string[] codecParameters)
 {
     if (entity == null || !(entity is SparqlEndpoint)) return;
     var sparqlEndpoint = entity as SparqlEndpoint;
     var client = BrightstarService.GetClient();
     using (var resultStream = client.ExecuteQuery(sparqlEndpoint.Store, sparqlEndpoint.SparqlQuery))
     {
         var resultsDoc = XDocument.Load(resultStream);
         var resultsWriter = new System.Xml.XmlTextWriter(response.Stream, Encoding.Unicode);
         resultsDoc.WriteTo(resultsWriter);
         resultsWriter.Flush();
     }
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:13,代码来源:SparqlResultCodec.cs

示例7: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int project_uid;

            if (int.TryParse(Request.QueryString["project"], out project_uid) == false)
                project_uid = 1;

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();

                writer.WriteStartElement("Report");
                writer.WriteAttributeString("project", project_uid.ToString());

                writer.WriteStartElement("Items");

                DB.LoadReportDeleted(project_uid,
                    delegate(int report_uid, string login_id, string ipaddr, DateTime reported_time, string relative_time, int callstack_uid, string funcname, string version, string filename, string assigned, string uservoice, int num_comments)
                    {
                        writer.WriteStartElement("Item");

                        writer.WriteAttributeString("report_uid", report_uid.ToString());
                        writer.WriteAttributeString("login_id", login_id);
                        writer.WriteAttributeString("ipaddr", ipaddr);
                        writer.WriteAttributeString("reported_time", reported_time.ToString());
                        writer.WriteAttributeString("relative_time", relative_time);
                        writer.WriteAttributeString("callstack_uid", callstack_uid.ToString());
                        writer.WriteAttributeString("assigned", assigned);
                        writer.WriteAttributeString("num_comments", num_comments.ToString());
                        this.WriteCData(writer, "Funcname", funcname);
                        this.WriteCData(writer, "Version", version);
                        this.WriteCData(writer, "Filename", filename);
                        this.WriteCData(writer, "Uservoice", uservoice);

                        writer.WriteEndElement();
                    }
                );
                writer.WriteEndElement(); // Items
                writer.WriteEndElement(); // Report
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
开发者ID:NtreevSoft,项目名称:Crashweb,代码行数:48,代码来源:ReportDeleted.aspx.cs

示例8: AddReport

 internal void AddReport(int errorCode, string errorMessage, object actual = null, object expected = null)
 {
     string path = Environment.GetFolderPath(Environment.SpecialFolder.Templates);
     string fileName = System.IO.Path.Combine(path,"WATF.xml");
     string data = "";
     List<WATF.Plugin.HPST.HPSTStruct.Message> messages = null;
     using (System.IO.FileStream fileStream = System.IO.File.Open(fileName, FileMode.OpenOrCreate))
     {
         using(StreamReader sr = new StreamReader(fileStream))
         {
             data = sr.ReadToEnd();
         }
     }
     XmlSerializer mySerializer = new XmlSerializer(typeof(List<WATF.Plugin.HPST.HPSTStruct.Message>), new Type[] { typeof(WATF.Plugin.HPST.HPSTStruct.ReportMessages) });
     if (data.Length > 1)
     {
         using (StreamReader mem2 = new StreamReader(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(data)), System.Text.Encoding.UTF8))
         {
             messages = new List<WATF.Plugin.HPST.HPSTStruct.Message>((List<WATF.Plugin.HPST.HPSTStruct.Message>)mySerializer.Deserialize(mem2));
         }
     }
     else
     {
         messages = new List<WATF.Plugin.HPST.HPSTStruct.Message>();
     }
     WATF.Plugin.HPST.HPSTStruct.Message message = new HPSTStruct.Message();
     message.ErrorCode = errorCode;
     message.ErrorMessage = errorMessage;
     if (actual == null) message.Actual = "Null Value";
     else message.Actual = actual.ToString();
     if (expected == null) message.Expected = "Null Value";
     else message.Expected = expected.ToString();
     message.DateTime = DateTime.Now.ToString();
     messages.Add(message);
     using (System.IO.FileStream fileStream = System.IO.File.Open(fileName, FileMode.OpenOrCreate))
     {
         using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(fileStream, Encoding.UTF8))
         {
             mySerializer.Serialize(writer, messages);
             writer.Flush();
         }
     }
 }
开发者ID:huangchaosuper,项目名称:watf,代码行数:43,代码来源:Base.cs

示例9: SaveDocument

        public static void SaveDocument(System.Xml.XmlDocument origDoc, System.IO.Stream strm, bool bDoReplace)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            if (bDoReplace)
                doc.LoadXml(origDoc.OuterXml.Replace("xmlns=\"\"", ""));

            using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(strm, System.Text.Encoding.UTF8))
            {
                xtw.Formatting = System.Xml.Formatting.Indented; // if you want it indented
                xtw.Indentation = 4;
                xtw.IndentChar = ' ';

                doc.Save(xtw);
                xtw.Flush();
                xtw.Close();
            } // End Using xtw

            doc = null;
        }
开发者ID:ststeiger,项目名称:ReportViewerWrapper,代码行数:20,代码来源:XmlTools.cs

示例10: SaveQuotes

        /// <summary>
        /// Saves movie quotes to an xml file 
        /// </summary>
        /// <param name="movie">IIMDbMovie object</param>
        /// <param name="xmlPath">path to save xml file to</param>
        /// <param name="overwrite">set to true to overwrite existing xml file</param>
        public static void SaveQuotes(
            IIMDbMovie movie, 
            string xmlPath, 
            bool overwrite)
        {
            System.Xml.XmlTextWriter xmlWr;

            try
            {
                if (File.Exists(xmlPath) == false
                    || overwrite)
                    if (movie.Quotes.Count > 0)
                    {
                        xmlWr = new System.Xml.XmlTextWriter(xmlPath, Encoding.Default)
                                    {Formatting = System.Xml.Formatting.Indented};

                        xmlWr.WriteStartDocument();
                        xmlWr.WriteStartElement("Quotes");
                        foreach (IList<IIMDbQuote> quoteBlock in movie.Quotes)
                        {
                            xmlWr.WriteStartElement("QuoteBlock");
                            foreach (IIMDbQuote quote in quoteBlock)
                            {
                                xmlWr.WriteStartElement("Quote");
                                xmlWr.WriteElementString("Character", quote.Character);
                                xmlWr.WriteElementString("QuoteText", quote.Text);
                                xmlWr.WriteEndElement();
                            }
                            xmlWr.WriteEndElement();
                        }
                        xmlWr.WriteEndElement();
                        xmlWr.WriteEndDocument();
                        xmlWr.Flush();
                        xmlWr.Close();
                    }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:stavrossk,项目名称:MeediFier_for_MeediOS,代码行数:47,代码来源:ExtraFilmDetailsFileIO.cs

示例11: GenerateTOC

        /// <summary>
        /// Automatically create the table of contents for the specified document.
        /// Insert an ID in the document if the heading doesn't have it.
        /// Returns the XHTML for the TOC
        /// </summary>
        public static string GenerateTOC(System.Xml.XmlDocument doc)
        {
            System.Xml.XmlNodeList headings = doc.SelectNodes("//*");

              Heading root = new Heading("ROOT", null, 0);
              int index = 0;
              GenerateHeadings(headings, root, ref index);

              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
              {
            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8);
            writer.WriteStartElement("div");
            root.WriteChildrenToXml(writer);
            writer.WriteEndElement();
            writer.Flush();

            stream.Seek(0, System.IO.SeekOrigin.Begin);
            System.IO.StreamReader reader = new System.IO.StreamReader(stream, System.Text.Encoding.UTF8);

            return reader.ReadToEnd();
              }
        }
开发者ID:Learion,项目名称:BruceToolSet,代码行数:27,代码来源:HTMLHeadingParser.cs

示例12: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int project_uid;
            int report_uid;
            string version;

            if (int.TryParse(Request.QueryString["project"], out project_uid) == false)
                project_uid = 1;

            if (int.TryParse(Request.QueryString["report_uid"], out report_uid) == false)
            {
                return;
            }

            version = Request.QueryString["version"];
            if (version != null)
            {
                version.Trim();
                if (version.Length == 0)
                    version = null;
            }

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Outputs");

                DB.ReserveReparse(project_uid, report_uid, version);

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
开发者ID:NtreevSoft,项目名称:Crashweb,代码行数:39,代码来源:ReportReserveReparse.aspx.cs

示例13: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int callstack_uid;

            if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false)
                callstack_uid = 1;

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Comment");

                writer.WriteAttributeString("callstack_uid", callstack_uid.ToString());

                DB.ForEachCallstackComment CommentWriter = delegate(string author, string comment, DateTime created)
                {
                    writer.WriteStartElement("Item");

                    writer.WriteAttributeString("author", author);
                    writer.WriteAttributeString("created", created.ToString());

                    writer.WriteCData(comment);

                    writer.WriteEndElement();
                };

                DB.LoadCallstackComment(callstack_uid, CommentWriter);

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
开发者ID:NtreevSoft,项目名称:Crashweb,代码行数:38,代码来源:CallstackComment.aspx.cs

示例14: run

	//Activate This Construntor to log All To Standard output
	//public TestClass():base(true){}

	//Activate this constructor to log Failures to a log file
	//public TestClass(System.IO.TextWriter tw):base(tw, false){}


	//Activate this constructor to log All to a log file
	//public TestClass(System.IO.TextWriter tw):base(tw, true){}

	//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES

	public void run()
	{
		Exception exp = null;
	
		DataSet ds1 = new DataSet();
		ds1.Tables.Add(GHTUtils.DataProvider.CreateParentDataTable());
		ds1.Tables.Add(GHTUtils.DataProvider.CreateChildDataTable());
		
		System.IO.StringWriter sw = new System.IO.StringWriter();
		System.Xml.XmlTextWriter xmlTW = new System.Xml.XmlTextWriter(sw);
		//write xml file, schema only
		ds1.WriteXmlSchema(xmlTW);
		xmlTW.Flush();


		System.IO.StringReader sr = new System.IO.StringReader(sw.ToString());
		System.Xml.XmlTextReader xmlTR = new System.Xml.XmlTextReader(sr);
		
		//copy both data and schema
		DataSet ds2 = new DataSet();
		ds2.ReadXmlSchema(xmlTR);
	
	
		//check xml schema
		try
		{
			BeginCase("ReadXmlSchema - Tables count");
			Compare(ds1.Tables.Count ,ds2.Tables.Count );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		try
		{
			BeginCase("ReadXmlSchema - Tables 0 Col count");
			Compare(ds2.Tables[0].Columns.Count ,ds1.Tables[0].Columns.Count  );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		try
		{
			BeginCase("ReadXmlSchema - Tables 1 Col count");
			Compare(ds2.Tables[1].Columns.Count  ,ds1.Tables[1].Columns.Count  );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		//check some colummns types
		try
		{
			BeginCase("ReadXmlSchema - Tables 0 Col type");
			Compare(ds2.Tables[0].Columns[0].GetType() ,ds1.Tables[0].Columns[0].GetType() );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		try
		{
			BeginCase("ReadXmlSchema - Tables 1 Col type");
			Compare(ds2.Tables[1].Columns[3].GetType() ,ds1.Tables[1].Columns[3].GetType() );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}
		
		//check that no data exists
		try
		{
			BeginCase("ReadXmlSchema - Table 1 row count");
			Compare(ds2.Tables[0].Rows.Count ,0);
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		try
		{
			BeginCase("ReadXmlSchema - Table 2 row count");
			Compare(ds2.Tables[1].Rows.Count ,0);
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}



	}
开发者ID:nlhepler,项目名称:mono,代码行数:97,代码来源:DataSet_ReadXmlSchema_X.cs

示例15: Ask

 public void Ask(SelectableSource source, TextWriter output)
 {
     bool result = Ask(source);
     if (MimeType == SparqlXmlQuerySink.MimeType || MimeType == "text/xml") {
         System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(output);
         w.Formatting = System.Xml.Formatting.Indented;
         w.WriteStartElement("sparql");
         w.WriteAttributeString("xmlns", "http://www.w3.org/2001/sw/DataAccess/rf1/result");
         w.WriteStartElement("head");
         w.WriteEndElement();
         w.WriteStartElement("boolean");
         w.WriteString(result ? "true" : "false");
         w.WriteEndElement();
         w.WriteEndElement();
         w.Flush();
     } else if (MimeType == "text/plain") {
         output.WriteLine(result ? "true" : "false");
     } else {
     }
 }
开发者ID:shariqatariq,项目名称:profiles-rns,代码行数:20,代码来源:SparqlEngine.cs


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