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


C# XmlWriter.Dispose方法代码示例

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


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

示例1: ReturnStreamedWriter

 private void ReturnStreamedWriter(XmlWriter xmlWriter)
 {
     Contract.Assert(xmlWriter != null, "xmlWriter MUST NOT be null");
     xmlWriter.Flush();
     xmlWriter.Dispose();
 }
开发者ID:shijiaxing,项目名称:wcf,代码行数:6,代码来源:TextMessageEncoder.cs

示例2: 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();
#if NETFX_CORE
            _writer.Dispose();
#else
            _writer.Close();
#endif

        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:100,代码来源:Serialization.cs

示例3: Diff

        private bool Diff()
        {
            bool flag = false;
            XmlWriterSettings xws = new XmlWriterSettings();
            xws.ConformanceLevel = ConformanceLevel.Auto;
            xws.CheckCharacters = false;
            _Writer = XmlWriter.Create(new StringWriter(_Output), xws);
            _Writer.WriteStartElement(String.Empty, "Root", String.Empty);

            flag = CompareChildren(this._SourceDoc, this._TargetDoc);

            _Writer.WriteEndElement();
            _Writer.Dispose();
            return flag;
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:15,代码来源:XmlDiff.cs


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