private void OnRemoveFacetCategory(PivotFacetCategory facetCategory) { foreach (PivotItem item in this.Items) { item.RemoveAllFacetValues(facetCategory.Name); } }
private PivotFacetCategory OnAddFacetCategory(PivotFacetCategory facetCategory) { if (this.FacetCategories.Contains(facetCategory.Name)) { throw new ArgumentException("Cannot add a duplicate facet category name (Letters already exists)"); } return(facetCategory); }
internal IComparable ValidateFacetValue(ICollectionDefinition definition, String facetCategoryName, IComparable value) { IComparable actualValue = value; if (definition.FacetCategories.Contains(facetCategoryName)) { PivotFacetCategory existingFacetCategory = definition.FacetCategories[facetCategoryName]; if ((existingFacetCategory.Type.IsValidValue(value) == false)) { actualValue = null; if (value is String) { try { actualValue = existingFacetCategory.Type.ParseValue((String)value); } catch (FormatException) { // Do nothing. } } if (actualValue == null) { throw new ArgumentException("Item Id " + this.Id + " has an incompatible value (type: " + value.GetType().Name + ") for facet category " + facetCategoryName); } } } else if ((this.ContainingCollection != null) && (this.ContainingCollection.InferFacetCategories)) { PivotFacetType facetType = PivotFacetType.IdentifyType(value); this.ContainingCollection.FacetCategories.Add(new PivotFacetCategory(facetCategoryName, facetType)); } else { throw new ArgumentException("Item Id " + this.Id + " has an incompatible value (type: " + value.GetType().Name + ") for facet category " + facetCategoryName); } return(actualValue); }
private PivotFacetCategory ParseFacetCategory(XmlReader xmlReader) { PivotFacetCategory facetCategory = null; while (xmlReader.Read()) { if (xmlReader.NodeType != XmlNodeType.Element) continue; if (xmlReader.LocalName == "FacetCategory") { String name = xmlReader.GetAttribute("Name"); String type = xmlReader.GetAttribute("Type"); facetCategory = new PivotFacetCategory(name, PivotFacetType.Parse(type)); String value = null; if ((value = xmlReader.GetAttribute("Format")) != null) { facetCategory.Format = value; } if ((value = xmlReader.GetAttribute("IsFilterVisible", PivotNamespace)) != null) { facetCategory.IsFilterVisible = Boolean.Parse(value); } if ((value = xmlReader.GetAttribute("IsMetaDataVisible", PivotNamespace)) != null) { facetCategory.IsMetaDataVisible = Boolean.Parse(value); } if ((value = xmlReader.GetAttribute("IsWordWheelVisible", PivotNamespace)) != null) { facetCategory.IsWordWheelVisible = Boolean.Parse(value); } } else if (xmlReader.LocalName == "SortOrder") { if (facetCategory == null) continue; String name = xmlReader.GetAttribute("Name"); facetCategory.SortOrder = new PivotFacetSortOrder(name); } else if (xmlReader.LocalName == "SortValue") { if (facetCategory == null) continue; if (facetCategory.SortOrder == null) continue; facetCategory.SortOrder.AddValue(xmlReader.GetAttribute("Value")); } } return facetCategory; }
private void DeriveFacetCategoriesFromItems(OleDbConnection connection) { String itemsCommandString = this.ItemsDataQuery; if (itemsCommandString == null) return; OleDbCommand command = new OleDbCommand(itemsCommandString, connection); OleDbDataReader dataReader = command.ExecuteReader(); for (int column = 0; column < dataReader.FieldCount; column++) { String name = dataReader.GetName(column).ToLowerInvariant(); if (OleDbSchemaConstants.Item.AllColumns.Contains(name)) continue; PivotFacetCategory facetCategory = new PivotFacetCategory(name, PivotFacetType.String); this.CachedCollectionData.FacetCategories.Add(facetCategory); m_facetCategoryMap.Add(facetCategory.Name, facetCategory); } }
private PivotFacetCategory OnAddFacetCategory(PivotFacetCategory facetCategory) { if (this.FacetCategories.Contains(facetCategory.Name)) { throw new ArgumentException("Cannot add a duplicate facet category name (Letters already exists)"); } return facetCategory; }
/// <summary> /// Formats a given value as a string based upon the default formatting of the named facet category. /// </summary> /// <remarks> /// This method is used principally by the <see cref="GetFacetValueAsString"/> and <see /// cref="GetAllFacetValuesAsString"/> methods, but any compatible value may be formatted using this method. /// </remarks> /// <param name="facetCategoryName">the name of the facet category whose default format should be used</param> /// <param name="value">the value to format</param> /// <returns>a formatted version of the given value</returns> /// <exception cref="ArgumentException">if given an incompatible value</exception> public String ConvertFacetValueToString(String facetCategoryName, IComparable value) { PivotFacetCategory facetCategory = this.CollectionDefinition.FacetCategories[facetCategoryName]; return(facetCategory.Type.FormatValue(value)); }
private void WriteFacetCategory(XmlWriter xmlWriter, PivotFacetCategory facetCategory) { xmlWriter.WriteStartElement("FacetCategory"); xmlWriter.WriteAttributeString("Name", facetCategory.Name); xmlWriter.WriteAttributeString("Type", facetCategory.Type.ToString()); if (facetCategory.Format != null) { xmlWriter.WriteAttributeString("Format", facetCategory.Format); } xmlWriter.WriteAttributeString("IsFilterVisible", PivotNamespace, facetCategory.IsFilterVisible.ToString().ToLowerInvariant()); xmlWriter.WriteAttributeString("IsMetaDataVisible", PivotNamespace, facetCategory.IsMetaDataVisible.ToString().ToLowerInvariant()); xmlWriter.WriteAttributeString("IsWordWheelVisible", PivotNamespace, facetCategory.IsWordWheelVisible.ToString().ToLowerInvariant()); if (facetCategory.SortOrder != null) { xmlWriter.WriteStartElement("Extension"); xmlWriter.WriteStartElement("SortOrder", PivotNamespace); xmlWriter.WriteAttributeString("Name", facetCategory.SortOrder.Name); foreach (String sortValue in facetCategory.SortOrder.Values) { xmlWriter.WriteStartElement("SortValue", PivotNamespace); xmlWriter.WriteAttributeString("Value", sortValue); xmlWriter.WriteEndElement(); // SortValue } xmlWriter.WriteEndElement(); // SortOrder xmlWriter.WriteEndElement(); // Extension } xmlWriter.WriteEndElement(); // FacetCategory }
private String GenerateSortValuesString(PivotFacetCategory facetCategory) { if (facetCategory.SortOrder == null) return null; String[] allValues = new String[facetCategory.SortOrder.Values.Count()]; int index = 0; foreach (String value in facetCategory.SortOrder.Values) { allValues[index++] = value; } String facetValueString = String.Join(OleDbSchemaConstants.FacetValueDelimiter, allValues); return facetValueString; }