private bool RegisterProperty(ModelObject modelObject, PropertyDescriptor propertyDescriptor, object value) { SearchableAttribute searchableAttribute = null; if (value == EditorSearchEngine <T> .requestPropertyQuery) { // Querying for the property value can be slow, so don't do it unless the property is searchable searchableAttribute = this.GetSearchableAttribute(propertyDescriptor); if (searchableAttribute.KeywordProvider != null) { value = propertyDescriptor.GetValue(modelObject); } else { value = null; } } // Querying for the search attribute can be slow, so don't do it unless the property value is non-null if (value != null) { if (searchableAttribute == null) { searchableAttribute = this.GetSearchableAttribute(propertyDescriptor); } if (searchableAttribute.KeywordProvider != null) { this.AddTerms(this.GetSearchItem(modelObject, propertyDescriptor), searchableAttribute.KeywordProvider.GetKeywords(value)); return(true); } } return(false); }
// Gets a search attribute for the property. The attribute source can be the // Property itself, the Type of the property, or the Default value of the search // attribute. The priority of these sources is: Property, Type, Default private SearchableAttribute GetSearchableAttribute(PropertyDescriptor propertyDescriptor) { // Check the Property SearchableAttribute searchableAttribute = this.GetSearchableAttribute(propertyDescriptor.Attributes); if (searchableAttribute != SearchableAttribute.Default) { return(searchableAttribute); } // Check the Type return(this.GetSearchableAttribute(propertyDescriptor.PropertyType)); }
static SearchableAttribute() { SearchableAttribute.Default = new SearchableAttribute(true); SearchableAttribute.keywordProviders = new Dictionary <Type, IKeywordProvider> (); }