public void XDocInXStreamingElement() { InputSpace.Contacts(ref _xDoc, ref _xmlDoc); XStreamingElement streamElement = new XStreamingElement("Root", _xDoc); Assert.Throws <InvalidOperationException>(() => streamElement.Save(new MemoryStream())); }
public void NamePropertySet() { XStreamingElement streamElement = new XStreamingElement("ThisWillChangeToContact"); streamElement.Name = "contact"; Assert.Equal("contact", streamElement.Name.ToString()); }
public void CreatingXElementsFromNewDev10Types(object t, Type type) { XElement e = new XElement("e1", new XElement("e2"), "text1", new XElement("e3"), t); e.Add(t); e.FirstNode.ReplaceWith(t); XNode n = e.FirstNode.NextNode; n.AddBeforeSelf(t); n.AddAnnotation(t); n.ReplaceWith(t); e.FirstNode.AddAfterSelf(t); e.AddFirst(t); e.Annotation(type); e.Annotations(type); e.RemoveAnnotations(type); e.ReplaceAll(t); e.ReplaceAttributes(t); e.ReplaceNodes(t); e.SetAttributeValue("a", t); e.SetElementValue("e2", t); e.SetValue(t); XAttribute a = new XAttribute("a", t); XStreamingElement se = new XStreamingElement("se", t); se.Add(t); Assert.Throws <ArgumentException>(() => new XDocument(t)); Assert.Throws <ArgumentException>(() => new XDocument(t)); }
public void AddWithNull() { XStreamingElement streamElement = new XStreamingElement("contact"); streamElement.Add(null); Assert.Equal("<contact />", streamElement.ToString()); }
public void XMLPropertyGet() { XElement contact = new XElement("contact", new XElement("phone", "925-555-0134")); XStreamingElement streamElement = new XStreamingElement("contact", contact.Element("phone")); Assert.Equal(contact.ToString(SaveOptions.None), streamElement.ToString(SaveOptions.None)); }
public Manifest Process(Manifest manifest, string outputFolder) { if (string.IsNullOrEmpty(manifest.SitemapOptions?.BaseUrl)) { return(manifest); } if (!manifest.SitemapOptions.BaseUrl.EndsWith("/", StringComparison.Ordinal)) { manifest.SitemapOptions.BaseUrl += '/'; } if (!Uri.TryCreate(manifest.SitemapOptions.BaseUrl, UriKind.Absolute, out var baseUri)) { Logger.LogWarning($"Base url {manifest.SitemapOptions.BaseUrl} is not in a valid uri format."); return(manifest); } if (manifest.SitemapOptions.Priority.HasValue && (manifest.SitemapOptions.Priority < 0 || manifest.SitemapOptions.Priority > 1)) { Logger.LogWarning($"Invalid priority {manifest.SitemapOptions.Priority}, priority must be between 0.0 and 1.0. Use default value 0.5 instead"); manifest.SitemapOptions.Priority = 0.5; } var sitemapDocument = new XStreamingElement(Namespace + "urlset", GetElements(manifest, baseUri)); var sitemapOutputFile = Path.Combine(outputFolder, SitemapName); Logger.LogInfo($"Sitemap file is successfully exported to {sitemapOutputFile}"); sitemapDocument.Save(sitemapOutputFile); return(manifest); }
private void Write(XmlWriter outputWriter) { outputWriter.WriteStartDocument(); XStreamingElement root = MakeDzcTree(); root.WriteTo(outputWriter); }
private static XStreamingElement ToXStreamingElement(DataCenterElement element) { var xElement = new XStreamingElement(element.Name); xElement.Add(element.Attributes.Select(attribute => new XAttribute(attribute.Name, attribute.Value))); xElement.Add(element.Children.Select(ToXStreamingElement)); return(xElement); }
public void ToStringAttributeAfterText() { var el = new XStreamingElement("foo", "text", new XAttribute("bar", "baz")); el.ToString(); }
public void ToString() { var el = new XStreamingElement("foo", new XAttribute("bar", "baz"), "text"); Assert.AreEqual("<foo bar=\"baz\">text</foo>", el.ToString()); }
private void Write(XmlWriter outputWriter) { outputWriter.WriteStartDocument(); //Write the XML declaration XStreamingElement root = MakeCxmlTree(); root.WriteTo(outputWriter); }
//[Variation(Priority = 0, Desc = "Name Property - Get")] public void NamePropertyGet() { XStreamingElement streamElement = new XStreamingElement("contact"); if (!streamElement.Name.ToString().Equals("contact")) { throw new TestFailedException(""); } }
//[Variation(Priority = 0, Desc = "Constructor - XStreamingElement(XName)")] public void XNameConstructor() { XStreamingElement streamElement = new XStreamingElement("contact"); if (!streamElement.ToString().Equals("<contact />")) { throw new TestFailedException(""); } }
private static string CreateJsonString(XStreamingElement element) { using (var ms = new MemoryStream()) using (var writer = JsonReaderWriterFactory.CreateJsonWriter(ms, Encoding.Unicode)) { element.WriteTo(writer); writer.Flush(); return(Encoding.Unicode.GetString(ms.ToArray())); } }
private void btnTimKiem_Click(object sender, EventArgs e) { XStreamingElement Tree = new XStreamingElement("ThongTin", from item in TapItem("F:\\File xml ROW\\ThongTin.xml") where (string)item.Element("Ten") == txtTen.Text || (string)item.Element("SoSao") == txtSoSao.Text || (string)item.Attribute("Phe") == Phe.Text select item ); textBox11.Text = Tree.ToString(); }
private XStreamingElement MakeItems() { int itemId = 0; var xmlItems = m_collection.Items.Select( item => new XStreamingElement(Xmlns + "I", MakeItemContent(item, itemId++)) ); XStreamingElement items = new XStreamingElement(Xmlns + "Items", xmlItems); return(items); }
//[Variation(Priority = 1, Desc = "Add(null)")] public void AddWithNull() { XStreamingElement streamElement = new XStreamingElement("contact"); streamElement.Add(null); if (!streamElement.ToString().Equals("<contact />")) { throw new TestFailedException(""); } }
//[Variation(Priority = 0, Desc = "Name Property - Set")] public void NamePropertySet() { XStreamingElement streamElement = new XStreamingElement("ThisWillChangeToContact"); streamElement.Name = "contact"; if (!streamElement.Name.ToString().Equals("contact")) { throw new TestFailedException(""); } }
//[Variation(Priority = 0, Desc = "XML Property")] public void XMLPropertyGet() { XElement contact = new XElement("contact", new XElement("phone", "925-555-0134")); XStreamingElement streamElement = new XStreamingElement("contact", contact.Element("phone")); if (!streamElement.ToString(SaveOptions.None).Equals(contact.ToString(SaveOptions.None))) { throw new TestFailedException(""); } }
public void XNameAndEmptyStringConstructor() { XElement contact = new XElement("contact", ""); XStreamingElement streamElement = new XStreamingElement("contact", ""); GetFreshStream(); streamElement.Save(_sourceStream); contact.Save(_targetStream); ResetStreamPos(); Assert.True(Diff.Compare(_sourceStream, _targetStream)); }
public void AddAttributeAfterContent() { XElement contact = new XElement("phone", new XAttribute("type", "home"), "925-555-0134"); XStreamingElement streamElement = new XStreamingElement("phone", "925-555-0134"); streamElement.Add(contact.Attribute("type")); using (XmlWriter w = XmlWriter.Create(new MemoryStream(), null)) { Assert.Throws <InvalidOperationException>(() => streamElement.WriteTo(w)); } }
public void Write(Stream output) { var content = new XStreamingElement(Ns + "Workbook", new XAttribute(XNamespace.Xmlns + "ss", Ns), new XStreamingElement(Ns + "Worksheet", new XAttribute(Ns + "Name", MainSheetName), new XStreamingElement(Ns + "Table", CreateHeaderRow(), CreateParameterRows()))); content.Save(output); }
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)); }
public void XStreamingElementInXDocument() { _xDoc = new XDocument(); XStreamingElement streamElement = new XStreamingElement("contacts", "SomeValue"); _xDoc.Add(streamElement); GetFreshStream(); streamElement.Save(_sourceStream); _xDoc.Save(_targetStream); ResetStreamPos(); Assert.True(Diff.Compare(_sourceStream, _targetStream)); }
public void AddObject(object content) { XElement contact = new XElement("phone", content); XStreamingElement streamElement = new XStreamingElement("phone"); streamElement.Add(content); GetFreshStream(); streamElement.Save(_sourceStream); contact.Save(_targetStream); ResetStreamPos(); Assert.True(Diff.Compare(_sourceStream, _targetStream)); }
//[Variation(Priority = 1, Desc = "Constructor - XStreamingElement('')")] public void XNameAsEmptyStringConstructor() { try { XStreamingElement streamElement = new XStreamingElement(" "); } catch (System.Xml.XmlException) { return; } throw new TestFailedException(""); }
//[Variation(Priority = 1, Desc = "Constructor - XStreamingElement(null)")] public void XNameAsNullConstructor() { try { XStreamingElement streamElement = new XStreamingElement(null); } catch (System.ArgumentNullException) { return; } throw new TestFailedException(""); }
public void AddTimeSpanObject() { XElement contact = new XElement("Time", TimeSpan.FromMinutes(12)); XStreamingElement streamElement = new XStreamingElement("Time"); streamElement.Add(TimeSpan.FromMinutes(12)); GetFreshStream(); streamElement.Save(_sourceStream); contact.Save(_targetStream); ResetStreamPos(); Assert.True(Diff.Compare(_sourceStream, _targetStream)); }
public void AddIEnumerableOfMixedNodes() { XElement element = new XElement("root", GetMixedNodes()); XStreamingElement streamElement = new XStreamingElement("root"); streamElement.Add(GetMixedNodes()); GetFreshStream(); streamElement.Save(_sourceStream); element.Save(_targetStream); ResetStreamPos(); Assert.True(Diff.Compare(_sourceStream, _targetStream)); }
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)); }
public void CreatingXElementsFromNewDev10Types(object t, Type type) { XElement e = new XElement("e1", new XElement("e2"), "text1", new XElement("e3"), t); e.Add(t); e.FirstNode.ReplaceWith(t); XNode n = e.FirstNode.NextNode; n.AddBeforeSelf(t); n.AddAnnotation(t); n.ReplaceWith(t); e.FirstNode.AddAfterSelf(t); e.AddFirst(t); e.Annotation(type); e.Annotations(type); e.RemoveAnnotations(type); e.ReplaceAll(t); e.ReplaceAttributes(t); e.ReplaceNodes(t); e.SetAttributeValue("a", t); e.SetElementValue("e2", t); e.SetValue(t); XAttribute a = new XAttribute("a", t); XStreamingElement se = new XStreamingElement("se", t); se.Add(t); Assert.Throws<ArgumentException>(() => new XDocument(t)); Assert.Throws<ArgumentException>(() => new XDocument(t)); }