Esempio n. 1
0
        private Dictionary <string, List <string> > MapDocumentFieldsToTypeIndexer(Type type, IEnumerable <string> documentFieldNames)
        {
            Dictionary <string, List <string> > dictionary = documentFieldNames.ToDictionary <string, string, List <string> >((Func <string, string>)(f => f.ToLowerInvariant()), (Func <string, List <string> >)(f => this.GetTypeFieldNames(f).ToList <string>()));

            foreach (PropertyInfo property in this.GetProperties(type))
            {
                string index        = property.Name;
                Type   propertyType = property.PropertyType;
                IIndexFieldNameFormatterAttribute formatterAttribute = this.GetIndexFieldNameFormatterAttribute((MemberInfo)property);
                string fieldName = property.Name;
                if (formatterAttribute != null)
                {
                    index     = formatterAttribute.GetIndexFieldName(index);
                    fieldName = formatterAttribute.GetTypeFieldName(fieldName);
                }
                if (!this.schema.AllFieldNames.Contains(index))
                {
                    SolrSearchFieldConfiguration fieldConfiguration = this.fieldMap.GetFieldConfiguration(propertyType) as SolrSearchFieldConfiguration;
                    if (fieldConfiguration != null)
                    {
                        index = fieldConfiguration.FormatFieldName(index, (ISearchIndexSchema)this.schema, this.currentCultureCode, (string)null);
                    }
                }
                if (dictionary.ContainsKey(index))
                {
                    dictionary[index].Add(fieldName);
                }
            }
            return(dictionary);
        }
 private Dictionary<string, List<string>> MapDocumentFieldsToTypeIndexer(Type type, IEnumerable<string> documentFieldNames)
 {
     Dictionary<string, List<string>> dictionary = Enumerable.ToDictionary<string, string, List<string>>(documentFieldNames, (Func<string, string>)(f => f), (Func<string, List<string>>)(f => Enumerable.ToList<string>(this.GetTypeFieldNames(f))));
     foreach (PropertyInfo propertyInfo in this.GetProperties(type))
     {
         IIndexFieldNameFormatterAttribute formatterAttribute = this.GetIndexFieldNameFormatterAttribute((MemberInfo)propertyInfo);
         if (formatterAttribute != null)
         {
             string indexFieldName = this.GetIndexFieldName(formatterAttribute.GetIndexFieldName(propertyInfo.Name));
             if (dictionary.ContainsKey(indexFieldName))
                 dictionary[indexFieldName].Add(formatterAttribute.GetTypeFieldName(propertyInfo.Name));
         }
     }
     return dictionary;
 }