/// <summary> /// Gets an enumeration of the search document fields from a data type. /// </summary> /// <param name="interfaceType"></param> /// <param name="includeDefaultFields"></param> /// <returns></returns> public static IEnumerable <DocumentField> GetDocumentFields(Type interfaceType, bool includeDefaultFields = true) { var fields = includeDefaultFields ? SearchDocumentBuilder.GetDefaultDocumentFields() : Enumerable.Empty <DocumentField>(); fields = fields.Concat( from info in GetSearchableFields(interfaceType) let prop = info.Key let attr = info.Value where attr.Previewable || attr.Faceted let processor = GetDataFieldProcessor(prop) select new DocumentField( processor.GetDocumentFieldName(prop), attr.Faceted ? processor.GetDocumentFieldFacet(prop) : null, attr.Previewable ? processor.GetDocumentFieldPreview(prop) : null) { Label = processor.GetFieldLabel(prop) }); if (includeDefaultFields) { fields = fields.Concat( ServiceLocator.GetServices <IDocumentFieldProvider>() .SelectMany(fp => fp.GetCustomFields(interfaceType))); } return(fields); }
/// <summary> /// Gets an enumeration of the search document fields from a data type. /// </summary> /// <param name="interfaceType"></param> /// <param name="includeDefaultFields"></param> /// <returns></returns> public static IEnumerable <DocumentField> GetDocumentFields(Type interfaceType, bool includeDefaultFields = true) { var defaultFields = includeDefaultFields ? SearchDocumentBuilder.GetDefaultDocumentFields() : Enumerable.Empty <DocumentField>(); return(defaultFields.Concat( from info in GetSearchableFields(interfaceType) let prop = info.Key let attr = info.Value where attr.Previewable || attr.Faceted let processor = GetDataFieldProcessor(prop) select new DocumentField( processor.GetDocumentFieldName(prop), attr.Faceted ? processor.GetDocumentFieldFacet(prop) : null, attr.Previewable ? processor.GetDocumentFieldPreview(prop) : null) { Label = processor.GetFieldLabel(prop) })); }