• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Linq.XStreamingElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



XStreamingElement类属于System.Xml.Linq命名空间,在下文中一共展示了XStreamingElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: XElement

		public XElement (XStreamingElement other)
		{
			if (other == null)
				throw new ArgumentNullException ("other");
			this.name = other.Name;
			Add (other.Contents);
		}
开发者ID:work-hrf,项目名称:mono,代码行数:7,代码来源:XElement.cs


示例2: WriteFile

        private void WriteFile(string targetDirectory, string entityNames, XStreamingElement fileContents)
        {
            var fileContentsWithHeader = @"<?xml version=""1.0"" encoding=""utf-8""?>" + Environment.NewLine + fileContents;

            var path = Path.Combine(targetDirectory, entityNames + ".xml");
            if (File.Exists(path))
            {
                var existingFileContents = File.ReadAllText(path);
                if (existingFileContents == fileContentsWithHeader)
                {
                    return;
                }

                var backupFolder = Path.Combine(targetDirectory, @"backup\");
                Directory.CreateDirectory(backupFolder);

                var fileNumber = GetFileNumber(backupFolder, entityNames);
                var backupFileName = String.Format("{0}.backup-{1}.xml", entityNames, fileNumber);

                var backupPath = Path.Combine(backupFolder, backupFileName);
                File.Move(path, backupPath);
            }

            File.WriteAllText(path, fileContentsWithHeader);
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:25,代码来源:FileWriter.cs


示例3: ToStringAttributeAfterText

		public void ToStringAttributeAfterText ()
		{
			var el = new XStreamingElement ("foo",
				"text",
				new XAttribute ("bar", "baz"));
			el.ToString ();
		}
开发者ID:nobled,项目名称:mono,代码行数:7,代码来源:XStreamingElementTest.cs


示例4: ToString

		public void ToString ()
		{
			var el = new XStreamingElement ("foo",
				new XAttribute ("bar", "baz"),
				"text");
			Assert.AreEqual ("<foo bar=\"baz\">text</foo>", el.ToString ());
		}
开发者ID:nobled,项目名称:mono,代码行数:7,代码来源:XStreamingElementTest.cs


示例5: XNameWithNamespaceConstructor

 public void XNameWithNamespaceConstructor()
 {
     XNamespace ns = @"http:\\www.contacts.com\";
     XElement contact = new XElement(ns + "contact");
     XStreamingElement streamElement = new XStreamingElement(ns + "contact");
     GetFreshStream();
     streamElement.Save(_sourceStream);
     contact.Save(_targetStream);
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:11,代码来源:StreamingOutput.cs


示例6: XNameAsEmptyStringConstructor

 //[Variation(Priority = 1, Desc = "Constructor - XStreamingElement('')")]
 public void XNameAsEmptyStringConstructor()
 {
     try
     {
         XStreamingElement streamElement = new XStreamingElement(" ");
     }
     catch (System.Xml.XmlException)
     {
         return;
     }
     throw new TestFailedException("");
 }
开发者ID:nnyamhon,项目名称:corefx,代码行数:13,代码来源:StreamingOutput.cs


示例7: XNameAsNullConstructor

 //[Variation(Priority = 1, Desc = "Constructor - XStreamingElement(null)")]
 public void XNameAsNullConstructor()
 {
     try
     {
         XStreamingElement streamElement = new XStreamingElement(null);
     }
     catch (System.ArgumentNullException)
     {
         return;
     }
     throw new TestFailedException("");
 }
开发者ID:nnyamhon,项目名称:corefx,代码行数:13,代码来源:StreamingOutput.cs


示例8: WriteXStreamingElementChildren

		public void WriteXStreamingElementChildren ()
		{
			var xml = "<?xml version='1.0' encoding='utf-8'?><root type='array'><item type='number'>0</item><item type='number'>2</item><item type='number'>5</item></root>".Replace ('\'', '"');
			
			var ms = new MemoryStream ();
			var xw = XmlWriter.Create (ms);
			int [] arr = new int [] {0, 2, 5};
			var xe = new XStreamingElement (XName.Get ("root"));
			xe.Add (new XAttribute (XName.Get ("type"), "array"));
			var at = new XAttribute (XName.Get ("type"), "number");
			foreach (var i in arr)
				xe.Add (new XStreamingElement (XName.Get ("item"), at, i));

			xe.WriteTo (xw);
			xw.Close ();
			Assert.AreEqual (xml, new StreamReader (new MemoryStream (ms.ToArray ())).ReadToEnd (), "#1");
		}
开发者ID:nobled,项目名称:mono,代码行数:17,代码来源:XStreamingElementTest.cs


示例9: WriteAccounts_creates_a_backup_and_overwrites_Account_file_if_it_has_changed

        public void WriteAccounts_creates_a_backup_and_overwrites_Account_file_if_it_has_changed()
        {
            _fileWriter.WriteAccountFile(TestDirectory);
            var originalTimestamp = File.GetLastWriteTimeUtc(_expectedAccountPath);

            Thread.Sleep(10);

            var modifiedAccountXml = new XStreamingElement("test", "someDifferentContent");
            _accountRepository.EmitXml().Returns(modifiedAccountXml);
            _fileWriter.WriteAccountFile(TestDirectory);

            var timestampAfterSecondWrite = File.GetLastWriteTimeUtc(_expectedAccountPath);

            Assert.AreNotEqual(originalTimestamp, timestampAfterSecondWrite);

            var backupPath = Path.Combine(TestDirectory, @"backup\", "accounts.backup-1.xml");

            Assert.IsTrue(File.Exists(backupPath));
            Assert.AreEqual(_accountXml.ToString(), File.ReadAllText(backupPath));
            Assert.AreEqual(originalTimestamp, File.GetLastWriteTimeUtc(backupPath));
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:21,代码来源:FileWriter_spec.cs


示例10: WriteStreamingElement

 internal void WriteStreamingElement(XStreamingElement e)
 {
     FlushElement();
     _element = e;
     Write(e.content);
     bool contentWritten = _element == null;
     FlushElement();
     if (contentWritten)
     {
         _writer.WriteFullEndElement();
     }
     else
     {
         _writer.WriteEndElement();
     }
     _resolver.PopScope();
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:17,代码来源:XLinq.cs


示例11: XNameAndNullObjectConstructor

 public void XNameAndNullObjectConstructor()
 {
     XStreamingElement streamElement = new XStreamingElement("contact", null);
     Assert.Equal("<contact />", streamElement.ToString());
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:5,代码来源:StreamingOutput.cs


示例12: XElement

		public XElement (XStreamingElement other)
		{
			this.name = other.Name;
			Add (other.Contents);
		}
开发者ID:user277,项目名称:mono,代码行数:5,代码来源:XElement.cs


示例13: XNameAndXElementObjectConstructor

 public void XNameAndXElementObjectConstructor()
 {
     XElement contact = new XElement("contact", new XElement("phone", "925-555-0134"));
     XStreamingElement streamElement = new XStreamingElement("contact", contact.Element("phone"));
     GetFreshStream();
     streamElement.Save(_sourceStream);
     contact.Save(_targetStream);
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:10,代码来源:StreamingOutput.cs


示例14: XStreamingElementSave_SaveOptions

 public void XStreamingElementSave_SaveOptions()
 {
     string markup = "<e a=\"value\"> <!--comment--> <e2> <![CDATA[cdata]]> </e2> <?pi target?> </e>";
     try
     {
         XElement e = XElement.Parse(markup, LoadOptions.PreserveWhitespace);
         XStreamingElement e2 = new XStreamingElement(e.Name, e.Attributes(), e.Nodes());
         e2.Save(_fileName, SaveOptions.DisableFormatting);
     }
     finally
     {
         Assert.True(File.Exists(_fileName));
         Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + markup, File.ReadAllText(_fileName));
         File.Delete(_fileName);
     }
 }
开发者ID:dotnet,项目名称:corefx,代码行数:16,代码来源:SaveWithFileName.cs


示例15: MakeItems

 private XStreamingElement MakeItems()
 {
     XStreamingElement items = new XStreamingElement(Xmlns + "Items", MakeItemsContent());
     return items;
 }
开发者ID:JuliettAlex,项目名称:Sales,代码行数:5,代码来源:CxmlSerializer.cs


示例16: MakeFacetCategories

 private XStreamingElement MakeFacetCategories()
 {
     XStreamingElement facetCats = new XStreamingElement(Xmlns + "FacetCategories", MakeFacetCategoriesContent());
     return facetCats;
 }
开发者ID:JuliettAlex,项目名称:Sales,代码行数:5,代码来源:CxmlSerializer.cs


示例17: MakeCxmlTree

 private XStreamingElement MakeCxmlTree()
 {
     XStreamingElement root = new XStreamingElement(Xmlns + "Collection", MakeCollectionContent());
     return root;
 }
开发者ID:JuliettAlex,项目名称:Sales,代码行数:5,代码来源:CxmlSerializer.cs


示例18: WriteStreamingElement

 internal void WriteStreamingElement(XStreamingElement e)
 {
     FlushElement();
     _element = e;
     Write(e.content);
     FlushElement();
     _writer.WriteEndElement();
     _resolver.PopScope();
 }
开发者ID:SamuelEnglard,项目名称:corefx,代码行数:9,代码来源:XLinq.cs


示例19: PropertyElement

 public PropertyElement(XStreamingElement other) : base(other)
 {
 }
开发者ID:LazyTarget,项目名称:Lux,代码行数:3,代码来源:CodeSyntaxTests.cs


示例20: XElement

 //
 // Summary:
 //     Initializes a new instance of the System.Xml.Linq.XElement class from an
 //     System.Xml.Linq.XStreamingElement object.
 //
 // Parameters:
 //   other:
 //     An System.Xml.Linq.XStreamingElement that contains unevaluated queries that
 //     will be iterated for the contents of this System.Xml.Linq.XElement.
 public XElement(XStreamingElement other)
 {
   Contract.Requires(other != null);
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:13,代码来源:System.Xml.Linq.XElement.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Linq.XText类代码示例发布时间:2022-05-26
下一篇:
C# Linq.XProcessingInstruction类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap