public void Can_get_an_artists_releases() { const string endpoint = "artist/releases"; var endPointInfo = new EndPointInfo { UriPath = endpoint, Parameters = new Dictionary<string,string> { { "artistId", "1" }, { "pageSize", "100" } } }; var response = _requestCoordinator.HitEndpoint(endPointInfo); dynamic dx = new DynamicXmlParser(XDocument.Parse(response.Body)); string [] titles = Enumerable.ToArray(Enumerable.Select<dynamic, string>(dx.releases.release, (Func<dynamic, string>) (r => r.title.value))); foreach (var title in titles) { Console.WriteLine(title); } Assert.That(titles.Count(), Is.GreaterThan(0)); }
public void Can_deal_with_xml() { string xml = "<books><book id='1'><name>Book with 2 authors</name><authors><author id='1'>Billy</author></authors></book><book id='2'><name>The Bobbit</name></book></books>"; dynamic dx = new DynamicXmlParser(xml); var condition = dx.book[1].name[0].Value; Assert.That(condition, Is.EqualTo("The Bobbit")); }
public void Can_get_an_artists_releases() { const string endpoint = "artist/releases"; var endPointInfo = new EndPointInfo { Uri = endpoint, Parameters = new Dictionary<string,string> { { "artistId", "1" } } }; string xml = _endpointResolver.HitEndpoint(endPointInfo); dynamic dx = new DynamicXmlParser(XDocument.Parse(xml)); string [] titles = Enumerable.ToArray(Enumerable.Select<dynamic, string>(dx.releases.release, (Func<dynamic, string>) (r => r.title.value))); foreach (var title in titles) { Console.WriteLine(title); } Assert.That(titles, Has.Member("Night Train").And.Member("Perfect Symmetry")); }
public void Can_get_an_artist() { const string endpoint = "artist/details"; var endPointInfo = new EndPointInfo { Uri = endpoint, Parameters = new Dictionary<string,string> { { "artistId", "1" } } }; string xml = _endpointResolver.HitEndpoint(endPointInfo); dynamic dx = new DynamicXmlParser(XDocument.Parse(xml)); var name = dx.artist[0].name.value; var sortName = dx.artist[0].sortName.value; var url = dx.artist[0].url.value; Assert.That(name, Is.EqualTo("Keane")); Assert.That(sortName, Is.EqualTo("Keane")); Assert.That(url, Is.StringStarting("http://www.7digital.com/artists/keane/")); }
private static void Main(string[] args) { dynamic parser = new DynamicXmlParser(@"D:\Private\Code\Examples\C#\AdslUsageData\DynamicCSVReaderTest\Configurations\Orders.xml"); Console.WriteLine(String.Format("Customer => \n\tName:{0} \n\tAddress: {1}\n" , parser.customer.name , parser.customer.address)); Console.WriteLine(String.Format("Product => \n\tName:{0} \n\tQuantity:{1} \n\tSupplier:{2}" , parser.orderItem.product , parser.orderItem.quantity , parser.orderItem.supplier)); ObjectBuilder builder = new ObjectBuilder(); Object bld = builder.BuildObjectInstance(@"D:\Private\Code\Examples\C#\AdslUsageData\DynamicCSVReaderTest\Configurations\ClassOrder.xml"); Console.ReadLine(); }
public void Can_get_an_artists_releases() { const string endpoint = "artist/releases"; var endPointInfo = new EndPointInfo { Uri = endpoint, Parameters = new NameValueCollection { { "artistId", "1" } } }; string xml = _endpointResolver.GetRawXml(endPointInfo); dynamic dx = new DynamicXmlParser(xml); var name = dx.releases.release[0].title.Value; var secondName = dx.releases.release[1].title.Value; Assert.That(name, Is.EqualTo("Night Train")); Assert.That(secondName, Is.EqualTo("Crystal Ball")); }
public void Can_get_an_artist() { const string endpoint = "artist/details"; var endPointInfo = new EndPointInfo { Uri = endpoint, Parameters = new NameValueCollection { { "artistId", "1" } } }; string xml = _endpointResolver.GetRawXml(endPointInfo); dynamic dx = new DynamicXmlParser(xml); var name = dx.artist[0].name.Value; var sortName = dx.artist[0].sortName.Value; var url = dx.artist[0].url.Value; Assert.That(name, Is.EqualTo("Keane")); Assert.That(sortName, Is.EqualTo("Keane")); Assert.That(url, Is.StringStarting("http://www.7digital.com/artists/keane/")); }
public ObservableCollection <Nodes> ParseXMLFile(string filePath) { ObservableCollection <Nodes> masterNodes = new ObservableCollection <Nodes>(); dynamic parser = new DynamicXmlParser(filePath); Nodes master = new Nodes(); ObservableCollection <NodeValues> nodelist = new ObservableCollection <NodeValues>(); NodeValues notevalues = new NodeValues(); var Name = (((DynamicXmlParser)parser)); var name = Name.element.Name.LocalName; var node = (XElement)Name.element.FirstNode; while (node != null) { if ((node.Name.ToString() != notevalues.Name) && node.PreviousNode != null) { master.Note = notevalues.Name; master.NoteValues = nodelist; masterNodes.Add(master); master = new Nodes(); nodelist = new ObservableCollection <NodeValues>(); } notevalues = new NodeValues(); notevalues.Name = node.Name.ToString(); if (((XElement)node).FirstAttribute != null) { notevalues.Number = ((XElement)node).FirstAttribute.Value; } notevalues.Value = ((XElement)node).FirstNode.ToString(); node = (XElement)node.NextNode; nodelist.Add(notevalues); if (node == null) { master.Note = notevalues.Name; master.NoteValues = nodelist; masterNodes.Add(master); } } return(masterNodes); }