public static FacetOptions Parse(string facets) { if (String.IsNullOrEmpty(facets)) { return(FacetOptions.Empty); } var facetOptions = new FacetOptions(); var parsedFields = FacetToken.Tokenize(facets); foreach (var field in parsedFields) { string name = field.String; int size = 25; var parts = field.String.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 2) { name = parts[0]; int partSize; if (Int32.TryParse(parts[1], out partSize)) { size = partSize; } } facetOptions.Fields.Add(new FacetField { Field = name, Size = size, Nested = field.Nested.Length == 0 ? null : FacetOptions.Parse(field.Nested), }); } return(facetOptions); }
public static FacetOptions Parse(string facets) { if (String.IsNullOrEmpty(facets)) return FacetOptions.Empty; var facetOptions = new FacetOptions(); var fields = facets.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var field in fields) { string name = field; int size = 25; var parts = field.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 2) { name = parts[0]; int partSize; if (Int32.TryParse(parts[1], out partSize)) size = partSize; } facetOptions.Fields.Add(new FacetField { Field = name, Size = size }); } return facetOptions; }