private SearchDescriptor <T> _Facet <F>( string name, Func <F, F> facet, Func <F, string> inferedFieldNameSelector, Action <FacetDescriptorsBucket <T>, F> fillBucket ) where F : new() { facet.ThrowIfNull("facet"); inferedFieldNameSelector.ThrowIfNull("inferedFieldNameSelector"); fillBucket.ThrowIfNull("fillBucket"); if (this._Facets == null) { this._Facets = new Dictionary <string, FacetDescriptorsBucket <T> >(); } var descriptor = new F(); var f = facet(descriptor); var key = string.IsNullOrWhiteSpace(name) ? inferedFieldNameSelector(descriptor) : name; if (string.IsNullOrWhiteSpace(key)) { throw new DslException( "Couldn't infer name for facet of type {0}".F(typeof(F).Name) ); } var bff = f as BaseFacetDescriptor <T>; var gff = f as GeoDistanceFacetDescriptor <T>; var bucket = new FacetDescriptorsBucket <T>(); if (bff != null) { bucket.Global = bff._IsGlobal; bucket.FacetFilter = bff._FacetFilter; bucket.Nested = bff._Nested; bucket.Scope = bff._Scope; } else if (gff != null) { bucket.Global = gff._IsGlobal; bucket.FacetFilter = gff._FacetFilter; bucket.Nested = gff._Nested; bucket.Scope = gff._Scope; } fillBucket(bucket, descriptor); this._Facets.Add(key, bucket); return(this); }
private SearchDescriptor <T> _Facet <F>( string name, Func <F, F> facet, Func <F, PropertyPathMarker> inferedFieldNameSelector, Action <FacetDescriptorsBucket <T>, F> fillBucket ) where F : IFacetDescriptor, new() { facet.ThrowIfNull("facet"); inferedFieldNameSelector.ThrowIfNull("inferedFieldNameSelector"); fillBucket.ThrowIfNull("fillBucket"); if (this._Facets == null) { this._Facets = new Dictionary <PropertyPathMarker, FacetDescriptorsBucket <T> >(); } var descriptor = new F(); var f = facet(descriptor); var key = string.IsNullOrWhiteSpace(name) ? inferedFieldNameSelector(descriptor) : name; if (key.IsConditionless()) { throw new DslException( "Couldn't infer name for facet of type {0}".F(typeof(F).Name) ); } var bucket = new FacetDescriptorsBucket <T>(); bucket.Global = f.IsGlobal; bucket.FacetFilter = f.FacetFilter; bucket.Nested = f.Nested; bucket.Scope = f.Scope; fillBucket(bucket, descriptor); this._Facets.Add(key, bucket); return(this); }