/// <summary> /// /// </summary> /// <remarks> /// This method was internal in the original design, but made it /// protected to make it easy to bring back the auto ranges feature if so desired. /// </remarks> /// <param name="choices"></param> /// <param name="max"></param> /// <returns></returns> // this is really crappy, need to fix it protected BrowseFacet[] FoldChoices(BrowseFacet[] choices, int max) { if (max == 0 || choices.Length <= max) { return(choices); } List <RangeFacet> list = new List <RangeFacet>(); for (int i = 0; i < choices.Length; i += 2) { RangeFacet rangeChoice = new RangeFacet(); if ((i + 1) < choices.Length) { if (choices is RangeFacet[]) { RangeFacet[] rChoices = (RangeFacet[])choices; string val1 = rChoices[i].Lower; string val2 = rChoices[i + 1].Upper; rangeChoice.SetValues(val1, val2); rangeChoice.FacetValueHitCount = choices[i].FacetValueHitCount + choices[i + 1].FacetValueHitCount; } else { rangeChoice.SetValues(choices[i].Value, choices[i + 1].Value); rangeChoice.FacetValueHitCount = choices[i].FacetValueHitCount + choices[i + 1].FacetValueHitCount; } } else { if (choices is RangeFacet[]) { RangeFacet[] rChoices = (RangeFacet[])choices; rangeChoice.SetValues(rChoices[i].Lower, rChoices[i].Upper); } else { rangeChoice.SetValues(choices[i].Value, choices[i].Value); } rangeChoice.FacetValueHitCount = choices[i].FacetValueHitCount; } list.Add(rangeChoice); } RangeFacet[] result = list.ToArray(); return(FoldChoices(result, max)); }
/// <summary> /// /// </summary> /// <remarks> /// This method was internal in the original design, but made it /// protected to make it easy to bring back the auto ranges feature if so desired. /// </remarks> /// <param name="facets"></param> protected virtual void ConvertFacets(BrowseFacet[] facets) { int i = 0; foreach (BrowseFacet facet in facets) { int hit = facet.FacetValueHitCount; string val = facet.Value; RangeFacet rangeFacet = new RangeFacet(); rangeFacet.SetValues(val, val); rangeFacet.FacetValueHitCount = hit; facets[i++] = rangeFacet; } }
// this is really crappy, need to fix it private BrowseFacet[] FoldChoices(BrowseFacet[] choices, int max) { if (max == 0 || choices.Length <= max) return choices; List<RangeFacet> list = new List<RangeFacet>(); for (int i = 0; i < choices.Length; i += 2) { RangeFacet rangeChoice = new RangeFacet(); if ((i + 1) < choices.Length) { if (choices is RangeFacet[]) { RangeFacet[] rChoices = (RangeFacet[])choices; object val1 = rChoices[i].Lower; object val2 = rChoices[i + 1].Upper; rangeChoice.SetValues(val1, val2); rangeChoice.HitCount = choices[i].HitCount + choices[i + 1].HitCount; } else { rangeChoice.SetValues(choices[i].Value, choices[i + 1].Value); rangeChoice.HitCount = choices[i].HitCount + choices[i + 1].HitCount; } } else { if (choices is RangeFacet[]) { RangeFacet[] rChoices = (RangeFacet[])choices; rangeChoice.SetValues(rChoices[i].Lower, rChoices[i].Upper); } else { rangeChoice.SetValues(choices[i].Value, choices[i].Value); } rangeChoice.HitCount = choices[i].HitCount; } list.Add(rangeChoice); } RangeFacet[] result = list.ToArray(); return FoldChoices(result, max); }
internal virtual void ConvertFacets(BrowseFacet[] facets) { int i = 0; foreach (BrowseFacet facet in facets) { int hit = facet.HitCount; object val = facet.Value; RangeFacet rangeFacet = new RangeFacet(); rangeFacet.SetValues(val, val); rangeFacet.HitCount = hit; facets[i++] = rangeFacet; } }