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


C# XmlWriter.Close方法代码示例

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


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

示例1: Write

		public static void Write(ProjectManager projects, string path, IdTable ids) {
			foreach ( var p in projects ) {
				if ( p == Project.Empty ) continue;
				var f = new XmlWriter(path + p.Name + ".xml");
				f.Begin(p, ids);
				f.Begin("Assignments");
				var faclist = new FlatAssignmentCollection[p.Assignments.Count];
				lock ( p.Assignments ) p.Assignments.CopyTo(faclist, 0);
				foreach ( var fac in faclist ) {
					f.Begin(fac, ids);
					var falist = new FlatAssignment[fac.Count];
					lock ( fac ) fac.CopyTo(falist, 0);
					foreach ( var fa in falist ) f.Write(fa, ids);
					f.End(fac);
				}
				f.End("Assignments");
				f.Begin("Costs");
				var costlist = new Cost[p.Costs.Count];
				lock ( p.Costs ) p.Costs.CopyTo(costlist, 0);
				foreach ( var c in costlist ) {
					f.Begin(c, ids);
					f.Begin("Options");
					var optionslist = new CostOptions[c.Options.Count];
					lock ( c.Options ) c.Options.CopyTo(optionslist, 0);
					foreach ( var o in optionslist ) f.Write(o, ids);
					f.End("Options");
					f.End(c);
				}
				f.End("Costs");
				f.End(p);
				f.Close();
			}
		}
开发者ID:Wolfury,项目名称:nebenkosten,代码行数:33,代码来源:Xml.cs

示例2: Write

        public void Write()
        {
            XmlWriterSettings xmlSetting = new XmlWriterSettings();
            xmlSetting.CloseOutput = true;
            xmlSetting.Encoding = Encoding.UTF8;
            xmlSetting.Indent = true;
            xmlSetting.NewLineChars = "\r\n";

            wr = XmlWriter.Create(GeneralConfig.AppDataPath + "Questionaries\\" + questionary.Category + ".xml", xmlSetting);
            wr.WriteStartDocument();
            wr.WriteStartElement("Questionary");
            wr.WriteStartAttribute("category");
            wr.WriteValue(questionary.Category);
            wr.WriteEndAttribute();

            wr.WriteStartAttribute("created");
            wr.WriteValue(questionary.Created.ToString());
            wr.WriteEndAttribute();

            wr.WriteStartAttribute("updated");
            wr.WriteValue(questionary.Updated.ToString());
            wr.WriteEndAttribute();

            wr.WriteStartAttribute("template");
            wr.WriteValue(questionary.TemplateId);
            wr.WriteEndAttribute();

            wr.WriteStartElement("Questions");
            WriteQuestions();
            wr.WriteEndElement();

            wr.WriteEndElement();
            wr.WriteEndDocument();
            wr.Close();
        }
开发者ID:foresightbrand,项目名称:kebibi,代码行数:35,代码来源:QuestionaryWriter.cs

示例3: EndXML

 // ***************************************************************************
 // Beendet an zu schreiben
 public static void EndXML(XmlWriter writer)
 {
     writer.WriteEndElement();
     writer.WriteEndDocument();
     writer.Flush();
     writer.Close();
 }
开发者ID:StWol,项目名称:Last-Man,代码行数:9,代码来源:XMLManager.cs

示例4: Write

        public void Write(XmlWriter writer, TestRunType testRun)
        {
            try
            {
                _serializer.Serialize(writer, testRun, new XmlSerializerNamespaces(new XmlQualifiedName[]
                                                                                       {
                                                                                           new XmlQualifiedName(string.Empty, "http://microsoft.com/schemas/VisualStudio/TeamTest/2010")
                                                                                       }));
            }
            catch (Exception)
            {

                throw;
            }
            finally
            {
                if (writer != null)
                {
                    try
                    {
                        writer.Close();
                    }
                    catch { }
                }
            }
        }
开发者ID:iinteractive,项目名称:IInteractive.WebTest,代码行数:26,代码来源:WebTestXmlWriter.cs

示例5: Minimize

        // ----------------------------------------------------------
        public void Minimize(Options aOptions, Def aDef)
        {
            // reader
            _reader = new XmlDocument();
            _reader.Load(aOptions.inFile);

            // writter with write settings
            var writterSettings = new XmlWriterSettings();
            if (aOptions.prettyPrint) {
                writterSettings.Indent = true;
                writterSettings.IndentChars = "  ";
            }
            _writer = XmlWriter.Create(aOptions.outFile, writterSettings);

            _writer.WriteStartDocument();

            ProcessElement(_reader.DocumentElement, aDef);

            _writer.WriteEndDocument();
            _writer.Close();

            // print warnings
            foreach(string warning in _warnings) {
                Console.WriteLine(warning);
            }
        }
开发者ID:SBCGames,项目名称:SpriterMinimizer,代码行数:27,代码来源:XmlMinimizer.cs

示例6: DbmlToFile

 public void DbmlToFile(Database db, string filename, Encoding encoding)
 {
     var settings = new XmlWriterSettings {Indent = true, Encoding = encoding};
     writer = XmlWriter.Create(filename, settings);
     VisitDatabase(db);
     writer.Flush();
     writer.Close();
 }
开发者ID:mattfrerichs,项目名称:Templates,代码行数:8,代码来源:DbmlSerializer.cs

示例7: SaveXml

		public void SaveXml(CompilationUnit cu)
		{
            try
            {
                this.cu = cu;
                is_assembly = cu.SyntaxTree is SyntaxTree.program_module || Compiler.is_dll(cu.SyntaxTree);
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Encoding = Encoding.UTF8;
                settings.Indent = true;
                xtw = XmlTextWriter.Create(Path.ChangeExtension(cu.UnitName, ".xml"), settings);
                unit_name = Path.GetFileNameWithoutExtension(cu.UnitName);
                xtw.WriteStartDocument();
                xtw.WriteStartElement("doc");
                if (is_assembly)
                {
                    xtw.WriteStartElement("assembly");
                    xtw.WriteStartElement("name");
                    xtw.WriteString(Path.GetFileNameWithoutExtension(cu.UnitName));
                    xtw.WriteEndElement();
                    xtw.WriteEndElement();
                }
                else
                {
                    xtw.WriteStartElement("unit");
                    xtw.WriteStartAttribute("name");
                    //xtw.WriteString((cu.SemanticTree as common_unit_node).unit_name);
                    xtw.WriteString(Path.GetFileNameWithoutExtension(cu.UnitName));
                    xtw.WriteEndAttribute();
                    xtw.WriteString(cu.SemanticTree.documentation);
                    xtw.WriteEndElement();
                }
                SaveMembers();
                xtw.WriteEndElement();
                xtw.Flush();
            }
            catch (Exception e)
            {

            }
			try
			{
				if (xtw != null)
					xtw.Close();
			}
			catch
			{
				
			}
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:49,代码来源:DocXml.cs

示例8: generate

        public void generate(CommonTree ast, XmlWriter writer)
        {
            try
            {
                writer.WriteStartDocument();

                writeXMLNode(ast, writer);

                writer.WriteEndDocument();
                writer.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error while translating AST: " + e.Message);
            }
        }
开发者ID:perfoon,项目名称:JavaScript-analyser,代码行数:16,代码来源:XmlTranslatorActivity.cs

示例9: WriteLevel

        public void WriteLevel(XmlWriter writer)
        {
            writer.WriteStartDocument();
             foreach (Level level in this.lstLevel.Items)
            level.ToXML(writer);

             writer.WriteStartElement("physics");
             foreach (Item p in this.lstPhysics.Items)
            p.ToXML(writer);
             writer.WriteEndElement();
             writer.WriteStartElement("actors");
             foreach (Item p in this.lstActors.Items)
            p.ToXML(writer);

             writer.WriteEndElement();
             writer.WriteEndDocument();
             writer.Close();
        }
开发者ID:jsj2008,项目名称:polukili,代码行数:18,代码来源:MainWindow.cs

示例10: DbmlToString

 public string DbmlToString(Database db, Encoding encoding)
 {
     string str;
     using (var stream = new MemoryStream())
     using (var streamWriter = new StreamWriter(stream, encoding))
     {
         var settings = new XmlWriterSettings {Indent = true, Encoding = encoding};
         writer = XmlWriter.Create(streamWriter, settings);
         VisitDatabase(db);
         writer.Flush();
         writer.Close();
         using (var reader = new StreamReader(stream, encoding))
         {
             stream.Position = 0L;
             str = reader.ReadToEnd();
         }
     }
     return str;
 }
开发者ID:mattfrerichs,项目名称:Templates,代码行数:19,代码来源:DbmlSerializer.cs

示例11: CreateXMLDoc

        public void CreateXMLDoc(String filePath)
        {
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.IndentChars = "\t";
            settings.NewLineChars = "\n";
            //settings.OmitXmlDeclaration = true; // "<?xml version="1.0" encoding="utf-8"?>"

            //writer = new XmlTextWriter(filePath, Encoding.Unicode);
            writer = XmlWriter.Create(filePath,settings);
            writer.WriteStartDocument();
            writer.WriteStartElement("map");        //
            //writer.WriteStartElement("name");

            //Writing name of the mode
            writer.WriteStartElement("mode");
            writer.WriteAttributeString("name", mode.mode.ToString());           //writer.WriteAttributeString("name", mode.getName());
            writer.WriteEndElement();

            //Writing map structure block
            writer.WriteStartElement("structure");      //
            //MapObject[][] tempMapObject = map.GetInternalForm();
            foreach (MapObject[] m in map.MapInstance)
            {
                for (int j = 0; j < m.Length; j++)
                {
                    writer.WriteStartElement("element");
                    writer.WriteAttributeString("x", m[j].X.ToString());
                    writer.WriteAttributeString("y", m[j].Y.ToString());
                    writer.WriteAttributeString("type", m[j].Type.ToString());
                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();

            writer.WriteEndElement();

            writer.WriteEndDocument();
            writer.Close();
        }
开发者ID:faulknercs,项目名称:BattleCityOnline,代码行数:40,代码来源:MapSaver.cs

示例12: WriteClientBinXml

        private void WriteClientBinXml(XmlWriter writer)
        {
            // Setup initial conditions.
            writer.WriteStartDocument();
            writer.WriteStartElement("ClientBin");

            // Enumerate the collection of XAP files.
            var folder = new DirectoryInfo(Server.MapPath("ClientBin"));
            foreach (var file in folder.GetFiles("*.xap"))
            {
                var kb = Math.Round(Decimal.Divide(file.Length, 1000), 2);

                writer.WriteStartElement("File");
                writer.WriteAttributeString("Extension", "xap");
                writer.WriteAttributeString("Kb", kb.ToString());
                writer.WriteString(file.Name.TrimEnd(".xap".ToCharArray()));
                writer.WriteEndElement(); // File.
            }

            // Finish up.
            writer.WriteEndElement(); // ClientBin.
            writer.WriteEndDocument();
            writer.Close();
        }
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:24,代码来源:ClientBin.aspx.cs

示例13: EventsToWriter


//.........这里部分代码省略.........
                            writer.WriteProcessingInstruction(page[idxEvent].String1, page[idxEvent].String2);
                            break;

                        case XmlEventType.Whitespace:
                            writer.WriteWhitespace(page[idxEvent].String1);
                            break;

                        case XmlEventType.String:
                            writer.WriteString(page[idxEvent].String1);
                            break;

                        case XmlEventType.Raw:
                            writer.WriteRaw(page[idxEvent].String1);
                            break;

                        case XmlEventType.EntRef:
                            writer.WriteEntityRef(page[idxEvent].String1);
                            break;

                        case XmlEventType.CharEnt:
                            writer.WriteCharEntity((char) page[idxEvent].Object);
                            break;

                        case XmlEventType.SurrCharEnt:
                            chars = (char[]) page[idxEvent].Object;
                            writer.WriteSurrogateCharEntity(chars[0], chars[1]);
                            break;

                        case XmlEventType.Base64:
                            bytes = (byte[]) page[idxEvent].Object;
                            writer.WriteBase64(bytes, 0, bytes.Length);
                            break;

                        case XmlEventType.BinHex:
                            bytes = (byte[]) page[idxEvent].Object;
                            writer.WriteBinHex(bytes, 0, bytes.Length);
                            break;

                        case XmlEventType.XmlDecl1:
                            if (rawWriter != null)
                                rawWriter.WriteXmlDeclaration((XmlStandalone) page[idxEvent].Object);
                            break;

                        case XmlEventType.XmlDecl2:
                            if (rawWriter != null)
                                rawWriter.WriteXmlDeclaration(page[idxEvent].String1);
                            break;

                        case XmlEventType.StartContent:
                            if (rawWriter != null)
                                rawWriter.StartElementContent();
                            break;

                        case XmlEventType.EndElem:
                            if (rawWriter != null)
                                rawWriter.WriteEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                            else
                                writer.WriteEndElement();
                            break;

                        case XmlEventType.FullEndElem:
                            if (rawWriter != null)
                                rawWriter.WriteFullEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                            else
                                writer.WriteFullEndElement();
                            break;

                        case XmlEventType.Nmsp:
                            if (rawWriter != null)
                                rawWriter.WriteNamespaceDeclaration(page[idxEvent].String1, page[idxEvent].String2);
                            else
                                writer.WriteAttributeString("xmlns", page[idxEvent].String1, XmlReservedNs.NsXmlNs, page[idxEvent].String2);
                            break;

                        case XmlEventType.EndBase64:
                            if (rawWriter != null)
                                rawWriter.WriteEndBase64();
                            break;

                        case XmlEventType.Close:
                            writer.Close();
                            break;

                        case XmlEventType.Flush:
                            writer.Flush();
                            break;

                        case XmlEventType.Dispose:
                            ((IDisposable)writer).Dispose();
                            break;

                        default:
                            Debug.Assert(false, "Unknown event: " + page[idxEvent].EventType);
                            break;
                    }
                }
            }

            Debug.Assert(false, "Unknown event should be added to end of event sequence.");
        }
开发者ID:uQr,项目名称:referencesource,代码行数:101,代码来源:XmlEventCache.cs

示例14: Serialize

        public void Serialize(World world, Stream stream)
        {
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.NewLineOnAttributes = false;
            settings.OmitXmlDeclaration = true;

            _writer = XmlWriter.Create(stream, settings);

            _writer.WriteStartElement("World");
            _writer.WriteAttributeString("Version", "2");
            WriteElement("Gravity", world.Gravity);

            _writer.WriteStartElement("Shapes");

            for (int i = 0; i < world.BodyList.Count; i++)
            {
                Body body = world.BodyList[i];
                for (int j = 0; j < body.FixtureList.Count; j++)
                {
                    Fixture fixture = body.FixtureList[j];

                    bool alreadyThere = false;
                    for (int k = 0; k < _serializedShapes.Count; k++)
                    {
                        Shape s2 = _serializedShapes[k];
                        if (fixture.Shape.CompareTo(s2))
                        {
                            alreadyThere = true;
                            break;
                        }
                    }

                    if (!alreadyThere)
                    {
                        SerializeShape(fixture.Shape);
                        _serializedShapes.Add(fixture.Shape);
                    }
                }
            }

            _writer.WriteEndElement();
            _writer.WriteStartElement("Fixtures");

            for (int i = 0; i < world.BodyList.Count; i++)
            {
                Body body = world.BodyList[i];
                for (int j = 0; j < body.FixtureList.Count; j++)
                {
                    Fixture fixture = body.FixtureList[j];
                    bool alreadyThere = false;
                    for (int k = 0; k < _serializedFixtures.Count; k++)
                    {
                        Fixture f2 = _serializedFixtures[k];
                        if (fixture.CompareTo(f2))
                        {
                            alreadyThere = true;
                            break;
                        }
                    }

                    if (!alreadyThere)
                    {
                        SerializeFixture(fixture);
                        _serializedFixtures.Add(fixture);
                    }
                }
            }

            _writer.WriteEndElement();
            _writer.WriteStartElement("Bodies");

            for (int i = 0; i < world.BodyList.Count; i++)
            {
                Body body = world.BodyList[i];
                _bodies.Add(body);
                SerializeBody(body);
            }

            _writer.WriteEndElement();
            _writer.WriteStartElement("Joints");

            for (int i = 0; i < world.JointList.Count; i++)
            {
                Joint joint = world.JointList[i];
                SerializeJoint(joint);
            }

            _writer.WriteEndElement();
            _writer.WriteEndElement();

            _writer.Flush();
            _writer.Close();
        }
开发者ID:vvnurmi,项目名称:assaultwing,代码行数:94,代码来源:Serialization.cs

示例15: WriteSoapEnvelopeEndAndClose

 public static void WriteSoapEnvelopeEndAndClose(XmlWriter writer)
 {
   writer.WriteEndElement(); // s:Body
   writer.WriteEndElement(); // s:Envelope
   writer.Close();
 }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:6,代码来源:SoapHelper.cs


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