Exemplo n.º 1
0
        public void TestParseMissingDelimiter()
        {
            PivotLink link = PivotLink.ParseValue("alpha bravo");

            AssertEqual("alpha bravo", link.Title);
            AssertNull(link.Url);
        }
Exemplo n.º 2
0
        private void ParseFacet(XmlReader xmlReader, PivotItem item)
        {
            PivotCollection cachedData = this.CachedCollectionData;

            String         facetCategoryName = null;
            PivotFacetType facetType         = null;

            while (xmlReader.Read())
            {
                if (xmlReader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                if (xmlReader.LocalName == "Facet")
                {
                    facetCategoryName = xmlReader.GetAttribute("Name");
                    PivotFacetCategory facetCategory = cachedData.FacetCategories[facetCategoryName];
                    facetType = facetCategory.Type;
                }
                else if ((facetType != null) && (xmlReader.LocalName == facetType.ToString()))
                {
                    if (facetType == PivotFacetType.Link)
                    {
                        PivotLink link = new PivotLink(xmlReader.GetAttribute("Name"), xmlReader.GetAttribute("Href"));
                        item.AddFacetValues(facetCategoryName, link);
                    }
                    else
                    {
                        String value = xmlReader.GetAttribute("Value");
                        item.AddFacetValues(facetCategoryName, facetType.ParseValue(value));
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void TestParseMissingUrl()
        {
            PivotLink link = PivotLink.ParseValue("alpha||");

            AssertEqual("alpha", link.Title);
            AssertNull(link.Url);
        }
Exemplo n.º 4
0
        public void TestParseMissingTitle()
        {
            PivotLink link = PivotLink.ParseValue("||bravo");

            AssertNull(link.Title);
            AssertEqual("bravo", link.Url);
        }
Exemplo n.º 5
0
        public void TestParseCorrectValue()
        {
            PivotLink link = PivotLink.ParseValue("alpha||bravo");

            AssertEqual("alpha", link.Title);
            AssertEqual("bravo", link.Url);
        }
Exemplo n.º 6
0
 public void AssertLinksEqual(PivotLink expected, PivotLink actual)
 {
     if (expected == null && actual == null)
     {
         return;
     }
     else if (expected != null && actual != null)
     {
         AssertEqual(expected.Title, actual.Title);
         AssertEqual(expected.Url, actual.Url);
     }
     else
     {
         Fail("Link comparison failed: one is null the other isn't");
     }
 }
Exemplo n.º 7
0
        private List <PivotLink> ParseRelatedLinks(XmlReader xmlReader)
        {
            List <PivotLink> relatedLinks = new List <PivotLink>();

            while (xmlReader.Read())
            {
                if (xmlReader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                if (xmlReader.LocalName == "Link")
                {
                    PivotLink link = new PivotLink(xmlReader.GetAttribute("Name"), xmlReader.GetAttribute("Href"));
                    relatedLinks.Add(link);
                }
            }
            return(relatedLinks);
        }
        private void WriteFacet(XmlWriter xmlWriter, String facetCategoryName, PivotItem item)
        {
            PivotFacetCategory facetCategory = item.CollectionDefinition.FacetCategories[facetCategoryName];

            xmlWriter.WriteAttributeString("Name", facetCategoryName);
            foreach (IComparable value in item.GetAllFacetValues(facetCategoryName))
            {
                if (facetCategory.Type == PivotFacetType.Link)
                {
                    PivotLink linkValue = (PivotLink)value;
                    xmlWriter.WriteStartElement(facetCategory.Type.ToString());
                    if (linkValue.Title != null)
                    {
                        xmlWriter.WriteAttributeString("Name", linkValue.Title);
                    }
                    if (linkValue.Url != null)
                    {
                        xmlWriter.WriteAttributeString("Href", linkValue.Url);
                    }
                    xmlWriter.WriteEndElement(); // FacetType
                }
                else if (facetCategory.Type == PivotFacetType.DateTime)
                {
                    xmlWriter.WriteStartElement(facetCategory.Type.ToString());
                    xmlWriter.WriteAttributeString("Value", ((DateTime)value).ToString("s"));
                    xmlWriter.WriteEndElement(); // FacetType
                }
                else if (facetCategory.Type == PivotFacetType.Number)
                {
                    xmlWriter.WriteStartElement(facetCategory.Type.ToString());
                    xmlWriter.WriteAttributeString("Value", value.ToString());
                    xmlWriter.WriteEndElement(); // FacetType
                }
                else
                {
                    xmlWriter.WriteStartElement(facetCategory.Type.ToString());
                    xmlWriter.WriteAttributeString("Value", item.ConvertFacetValueToString(facetCategoryName, value));
                    xmlWriter.WriteEndElement(); // FacetType
                }
            }
        }