protected override Facets.Facet BuildFacet( Overture.ServiceModel.Search.Facet facetResult, FacetSetting setting, List <FacetValue> facetValues, CultureInfo cultureInfo) { var facet = new Facets.Facet { Title = facetResult.Title, FieldName = facetResult.FieldName, Quantity = facetValues.Sum(value => value.Quantity), FacetType = FacetType, SortWeight = setting.SortWeight, StartValue = facetResult.StartValue, EndValue = facetResult.EndValue, GapSize = facetResult.GapSize, IsDisplayed = setting.IsDisplayed }; //In order to always see selected facet values var selectedValueCount = facetValues.Count(x => x.IsSelected); var maxCollapsedValueCount = selectedValueCount > setting.MaxCollapsedValueCount ? selectedValueCount : setting.MaxCollapsedValueCount; facet.FacetValues = facetValues.Take(maxCollapsedValueCount).ToList(); facet.OnDemandFacetValues = facetValues .Skip(maxCollapsedValueCount) .Take(setting.MaxExpendedValueCount - setting.MaxCollapsedValueCount) .ToList(); return(facet); }
protected virtual Facets.Facet BuildFacet(Overture.ServiceModel.Search.Facet facetResult, FacetSetting setting, List <FacetValue> facetValues, CultureInfo cultureInfo) { var facet = new Facets.Facet { Title = facetResult.Title, FieldName = facetResult.FieldName, Quantity = facetValues.Count, FacetType = FacetType, SortWeight = setting.SortWeight, IsDisplayed = !facetValues.Any(value => value.IsPromoted) && setting.IsDisplayed }; //In order to always see selected facet values var selectedValueIndex = facetValues.FindLastIndex(x => x.IsSelected); var maxExpendedValueCount = selectedValueIndex > setting.MaxExpendedValueCount ? selectedValueIndex : (setting.MaxExpendedValueCount - setting.MaxCollapsedValueCount); facet.FacetValues = facetValues.Take(setting.MaxCollapsedValueCount).ToList(); facet.OnDemandFacetValues = facetValues .Skip(setting.MaxCollapsedValueCount) .Take(maxExpendedValueCount) .ToList(); return(facet); }