public Films Info(XmlNode node) { Films search = new Films(); search.city = node.Attributes.GetNamedItem("CITY").Value; search.cinema = node.Attributes.GetNamedItem("CINEMA").Value; search.movie = node.Attributes.GetNamedItem("MOVIE").Value; search.date = node.Attributes.GetNamedItem("DATE").Value; search.time = node.Attributes.GetNamedItem("TIME").Value; search.price = node.Attributes.GetNamedItem("PRICE").Value; return(search); }
public bool Compare(Films obj) { if ((this.city == obj.city) && (this.cinema == obj.cinema) && (this.movie == obj.movie) && (this.date == obj.date) && (this.time == obj.time) && (this.price == obj.price)) { return(true); } else { return(false); } }
public List <Films> AnalyzeFile(Films mySearch, string path) { XmlReader reader = XmlReader.Create(path); List <Films> result = new List <Films>(); Films find = null; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "film") { find = new Films(); while (reader.MoveToNextAttribute()) { if (reader.Name == "CITY") { find.city = reader.Value; } if (reader.Name == "CINEMA") { find.cinema = reader.Value; } if (reader.Name == "MOVIE") { find.movie = reader.Value; } if (reader.Name == "DATE") { find.date = reader.Value; } if (reader.Name == "TIME") { find.time = reader.Value; } if (reader.Name == "PRICE") { find.price = reader.Value; } } result.Add(find); } } } lastResult = Filter(result, mySearch); return(lastResult); }
private List <Films> Filter(List <Films> allRes, Films myTemplate) { List <Films> newResult = new List <Films>(); if (allRes != null) { foreach (Films i in allRes) { if ((myTemplate.city == i.city || myTemplate.city == null) && (myTemplate.cinema == i.cinema || myTemplate.cinema == null) && (myTemplate.movie == i.movie || myTemplate.movie == null) && (myTemplate.date == i.date || myTemplate.date == null) && (myTemplate.time == i.time || myTemplate.time == null) && (myTemplate.price == i.price || myTemplate.price == null)) { newResult.Add(i); } } } return(newResult); }
public List <Films> CheckNodes(List <List <Films> > list, Films myTemplate) { List <Films> newResult = new List <Films>(); foreach (List <Films> elem in list) { foreach (Films s in elem) { if ((myTemplate.city == s.city || myTemplate.city == null) && (myTemplate.cinema == s.cinema || myTemplate.cinema == null) && (myTemplate.movie == s.movie || myTemplate.movie == null) && (myTemplate.date == s.date || myTemplate.date == null) && (myTemplate.time == s.time || myTemplate.time == null) && (myTemplate.price == s.price || myTemplate.price == null)) { newResult.Add(s); } } } return(newResult); }
public List <Films> Cross(List <List <Films> > list, Films myTemplate) { List <Films> result = new List <Films>(); List <Films> clear = CheckNodes(list, myTemplate); foreach (Films elem in clear) { bool isIn = false; foreach (Films s in result) { if (s.Compare(elem)) { isIn = true; } } if (!isIn) { result.Add(elem); } } return(result); }
private void Parsing4XML() { Films myTemplate = OurSearch(); List <Films> res; if (radioDOM.Checked) { IStrategy parser = new DOM(); res = parser.AnalyzeFile(myTemplate, path); Output(res); } else if (radioSAX.Checked) { IStrategy parser = new SAX(); res = parser.AnalyzeFile(myTemplate, path); Output(res); } else if (radioLINQ.Checked) { IStrategy parser = new LINQToXML(); res = parser.AnalyzeFile(myTemplate, path); Output(res); } }
public List <Films> AnalyzeFile(Films mySearch, string path) { document.Load(path); List <List <Films> > info = new List <List <Films> >(); if (mySearch.city == null && mySearch.cinema == null && mySearch.movie == null && mySearch.date == null && mySearch.time == null && mySearch.price == null) { return(ErrorCatch(document)); } if (mySearch.city != null) { info.Add(SearchByAttribute("film", "CITY", mySearch.city, document)); } if (mySearch.cinema != null) { info.Add(SearchByAttribute("film", "CINEMA", mySearch.cinema, document)); } if (mySearch.movie != null) { info.Add(SearchByAttribute("film", "MOVIE", mySearch.movie, document)); } if (mySearch.date != null) { info.Add(SearchByAttribute("film", "DATE", mySearch.date, document)); } if (mySearch.time != null) { info.Add(SearchByAttribute("film", "TIME", mySearch.time, document)); } if (mySearch.price != null) { info.Add(SearchByAttribute("film", "PRICE", mySearch.price, document)); } return(Cross(info, mySearch)); }