/// <summary> /// Gets the count of a given facet value. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="result">The <see cref="FacetResult"/> in which to find the value count.</param> /// <param name="value">The value for which to get the count.</param> /// <returns>Returns the count if found, otherwise 0.</returns> /// <exception cref="ArgumentNullException">Thrown if one of the parameters is null.</exception> public int Evaluate(IMansionContext context, FacetResult result, string value) { // validate arguments if (context == null) throw new ArgumentNullException("context"); if (result == null) throw new ArgumentNullException("result"); if (value == null) throw new ArgumentNullException("value"); // get the value var facetValue = result.Values.FirstOrDefault(candidate => value.Equals(candidate.Value.ToString(), StringComparison.OrdinalIgnoreCase)); // return the count return facetValue != null ? facetValue.Count : 0; }
/// <summary> /// Adds an <see cref="FacetResult"/> to this nodeset. /// </summary> /// <param name="result">The <see cref="FacetResult"/> which to add.</param> public void AddFacet(FacetResult result) { // validate arguments if (result == null) throw new ArgumentNullException("result"); // add the result facetResults.Add(result); }
/// <summary> /// Removes the given <paramref name="facet"/> from the <see cref="Facet"/>s. /// </summary> /// <param name="facet">The <see cref="FacetResult"/> which to remove.</param> public void RemoveFacet(FacetResult facet) { // validate arguments if (facet == null) throw new ArgumentNullException("facet"); // remove the facet facetResults.Remove(facet); }