/// <summary> /// Creates a new instance of <see cref="FacetPredicate"/> based on a <param name="filter"></param> object. /// </summary> public virtual FacetPredicate CreateFacetPredicate(SearchFilter filter) { if (filter == null) { throw new ArgumentNullException("filter"); } if (string.IsNullOrWhiteSpace(filter.Name)) { throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Name"), "filter"); } var setting = FacetConfigContext.GetFacetSettings() .FirstOrDefault(s => s.FieldName.Equals(filter.Name, StringComparison.OrdinalIgnoreCase)); if (setting == null) { return(null); } Type factoryType = FacetPredicateProviderRegistry.ResolveProviderType(setting.FacetType.ToString()); var instance = GetProviderInstance(factoryType); return(instance.CreateFacetPredicate(filter)); }
public virtual FacetPredicate CreateFacetPredicate(string facetName, string facetValue) { if (string.IsNullOrWhiteSpace(facetName)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(facetName))); } if (string.IsNullOrWhiteSpace(facetValue)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(facetValue))); } var setting = FacetConfigContext.GetFacetSettings().Find(s => s.FieldName.Equals(facetName, StringComparison.OrdinalIgnoreCase)); var facetType = setting == null?Orckestra.Composer.Search.Facets.FacetType.MultiSelect.ToString() : setting.FacetType.ToString(); Type factoryType = FacetPredicateProviderRegistry.ResolveProviderType(facetType); var instance = GetProviderInstance(factoryType); return(instance.CreateFacetPredicate(new SearchFilter() { Name = facetName, Value = facetValue })); }