Esempio n. 1
0
        public string GetIndexFieldName(MemberInfo member, CultureInfo culture)
        {
            string fieldName = member.Name;
            IIndexFieldNameFormatterAttribute formatterAttribute = this.GetIndexFieldNameFormatterAttribute(member);

            if (formatterAttribute != null)
            {
                fieldName = formatterAttribute.GetIndexFieldName(member.Name);
            }
            Type returnType;

            if ((object)(member as PropertyInfo) != null)
            {
                returnType = ((PropertyInfo)member).PropertyType;
            }
            else
            {
                if ((object)(member as FieldInfo) == null)
                {
                    throw new NotSupportedException("Unexpected member type: " + member.GetType().FullName);
                }
                returnType = ((FieldInfo)member).FieldType;
            }
            return(this.ProcessFieldName(fieldName, returnType, culture, "", false));
        }
 public override string GetIndexFieldName(MemberInfo member)
 {
     IIndexFieldNameFormatterAttribute formatterAttribute = this.GetIndexFieldNameFormatterAttribute(member);
     if (formatterAttribute != null)
         return this.GetIndexFieldName(formatterAttribute.GetIndexFieldName(member.Name));
     return this.GetIndexFieldName(member.Name);
 }
Esempio n. 3
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;
 }