private void BuildFieldMap(IEnumerable <PropertyInfo> props) { foreach (var p in props) { if (p.GetCustomAttribute <IgnoreFieldAttribute>(true) != null) { continue; } var mappingContext = FieldMappingInfoBuilder.Build <T>(p, version, externalAnalyzer); fieldMap.Add(mappingContext.PropertyName, mappingContext); if (!string.IsNullOrWhiteSpace(mappingContext.FieldName) && mappingContext.Analyzer != null) { analyzer.AddAnalyzer(mappingContext.FieldName, mappingContext.Analyzer); } } }
internal static ReflectionFieldMapper <T> BuildNumeric <T>(PropertyInfo p, Type type, NumericFieldAttribute metadata) { var fieldName = metadata.Field ?? p.Name; var typeToValueTypeConverter = GetComplexTypeToScalarConverter(type, metadata); var valueTypeToStringConverter = (TypeConverter)null; if (typeToValueTypeConverter != null) { valueTypeToStringConverter = GetScalarToStringConverter(typeToValueTypeConverter); } else { valueTypeToStringConverter = FieldMappingInfoBuilder.GetConverter(p, type, null); } return(new NumericReflectionFieldMapper <T>(p, metadata.Store, typeToValueTypeConverter, valueTypeToStringConverter, fieldName, metadata.PrecisionStep, metadata.Boost)); }
public ReflectionDocumentMapper(Type type) { var props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (var p in props) { if (p.GetCustomAttribute <IgnoreFieldAttribute>(true) != null) { continue; } var mappingContext = FieldMappingInfoBuilder.Build <T>(p); fieldMap.Add(mappingContext.PropertyInfo.Name, mappingContext); } var keyProps = from p in props let a = p.GetCustomAttribute <BaseFieldAttribute>(true) where a != null && a.Key select p; keyFields = keyProps.Select(kp => fieldMap[kp.Name]).ToList(); }