private static bool Equal <T>(FacetValues leftValues, FacetValues rightValues, string facetName) { var description = FacetDescriptionHelpers.GetFacetDescription <T>(facetName); Facet leftFacet = null; var leftHasValue = leftValues.TryGetFacet(description, out leftFacet); Facet rightFacet = null; var rightHasValue = rightValues.TryGetFacet(description, out rightFacet); return((leftHasValue && rightHasValue && EqualityComparer <T> .Default.Equals((T)leftFacet.Value, (T)rightFacet.Value)) || (!leftHasValue && !rightHasValue)); }
private static IEnumerable <Facet> OverrideFacetValues <T>( IEnumerable <T> facetThings, Func <T, FacetDescription> getDescription, Func <T, Facet> getFacet, FacetValues values) { foreach (T facetThing in facetThings) { FacetDescription description = getDescription(facetThing); Facet facet; if (!description.IsConstant && values.TryGetFacet(description, out facet)) { yield return(facet); } else { yield return(getFacet(facetThing)); } } }