예제 #1
0
        protected override IEnumerable <PivotItem> LoadItems()
        {
            XPathHelper document = null;

            using (WebClient webClient = new WebClient())
            {
                document = new XPathHelper(webClient.DownloadString(this.BasePath));
            }

            int index = 0;

            foreach (XPathHelper itemNode in document.FindNodes("//item"))
            {
                PivotItem item = new PivotItem(index.ToString(), this);

                String value = null;
                if (itemNode.TryFindString("title", out value))
                {
                    item.Name = value;
                }

                if (itemNode.TryFindString("description", out value))
                {
                    item.Description = value;
                }

                if (itemNode.TryFindString("link", out value))
                {
                    item.Href = value;
                }

                if (itemNode.TryFindString("author", out value))
                {
                    item.AddFacetValues("Author", value);
                }

                foreach (XPathHelper categoryNode in itemNode.FindNodes("category"))
                {
                    item.AddFacetValues("Category", categoryNode.FindString("."));
                }

                if (itemNode.TryFindString("pubDate", out value))
                {
                    DateTime dateValue = DateTime.Now;
                    if (DateTime.TryParse(value, out dateValue))
                    {
                        item.AddFacetValues("Date", dateValue);
                    }
                }

                yield return(item);

                index++;
            }
        }
예제 #2
0
        protected override IEnumerable<PivotItem> LoadItems()
        {
            XPathHelper document = null;
            using (WebClient webClient = new WebClient())
            {
                document = new XPathHelper(webClient.DownloadString(this.BasePath));
            }

            int index = 0;
            foreach (XPathHelper itemNode in document.FindNodes("//item"))
            {
                PivotItem item = new PivotItem(index.ToString(), this);

                String value = null;
                if (itemNode.TryFindString("title", out value))
                {
                    item.Name = value;
                }

                if (itemNode.TryFindString("description", out value))
                {
                    item.Description = value;
                }

                if (itemNode.TryFindString("link", out value))
                {
                    item.Href = value;
                }

                if (itemNode.TryFindString("author", out value))
                {
                    item.AddFacetValues("Author", value);
                }

                foreach (XPathHelper categoryNode in itemNode.FindNodes("category"))
                {
                    item.AddFacetValues("Category", categoryNode.FindString("."));
                }

                if (itemNode.TryFindString("pubDate", out value))
                {
                    DateTime dateValue = DateTime.Now;
                    if (DateTime.TryParse(value, out dateValue))
                    {
                        item.AddFacetValues("Date", dateValue);
                    }
                }

                yield return item;
                index++;
            }
        }