コード例 #1
0
        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);
        }
コード例 #2
0
        // 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));
        }
コード例 #3
0
 static SearchableAttribute()
 {
     SearchableAttribute.Default          = new SearchableAttribute(true);
     SearchableAttribute.keywordProviders = new Dictionary <Type, IKeywordProvider> ();
 }