public static FacetItem getFacetItem(filtersection fs, string fh_location, filter f)
 {
     FacetItem item = new FacetItem {
         FHId = fs.value.Value,
         NumItems = fs.nr,
         Selected = fs.selected
     };
     link link = fs.link;
     item.Text = link.name;
     Query query = new Query();
     query.ParseQuery(link.urlparams);
     query.removeListStartIndex();
     string urlParams = string.Empty;
     if (fs.selected)
     {
         string str2 = query.getLocation().getLastCriterion().toString();
         string facetValue = str2.Substring(str2.IndexOf('{') + 1).Replace("}", "");
         urlParams = RemoveFacetValues(fh_location, query.getLocation().getLastCriterion().getAttributeName(), facetValue);
     }
     else
     {
         Location location = new Location(fh_location);
         location.addCriterion(query.getLocation().getLastCriterion());
         urlParams = location.toString();
         if ((f.customfields != null) && (f.customfields.SingleOrDefault<customfield>(c => (c.name == "RefineMethod")).Value == "CombineFacets"))
         {
             urlParams = CreateOrCondition(urlParams);
         }
     }
     Location location2 = new Location(urlParams);
     query.setLocation(location2);
     item.Value = query.ToFhParams();
     return item;
 }
 public static FacetSection getChildSectionRecursive(filter child, string fh_location, IEnumerable<filter> childFilters)
 {
     FacetSection childSection = new FacetSection();
     childSection.Facets = new List<FacetItem>();
     childSection.SectionTitle = child.title;
     childSection.CustomFields = child.customfields;
     List<filtersection> childFilterSections = child.filtersection.ToList();
     foreach (var cfs in childFilterSections)
     {
         FacetItem childFacetItem = getFacetItem(cfs, fh_location, child);
         if (childFacetItem != null)
         {
             childFacetItem.Selected = cfs.selected;
             var rChild = childFilters.Where(s => s.on == cfs.value.Value).FirstOrDefault();
             if (rChild != null)
             {
                 childFacetItem.childSection = getChildSectionRecursive(rChild, fh_location, childFilters);
             }
             childSection.Facets.Add(childFacetItem);
         }
     }
     return childSection;
 }