Exemple #1
0
        public virtual SortDescriptor <T> OnField(Expression <Func <T, object> > objectPath)
        {
            var fieldName = new PropertyNameResolver().Resolve(objectPath);

            return(this.OnField(fieldName));
        }
 public SourcedPropertyNameResolver(Type sourceType, PropertyNameResolver inner)
 {
     this.inner   = inner;
     SourceType   = sourceType;
     PropertyName = inner.SourcePropertyName;
 }
Exemple #3
0
        public K FieldValue <K>(Expression <Func <T, object> > objectPath)
        {
            var path = new PropertyNameResolver().Resolve(objectPath);

            return(this.FieldValue <K>(path));
        }
Exemple #4
0
        internal void WriteProperties(JsonWriter jsonWriter)
        {
            var properties = this._type.GetProperties();
            foreach (var p in properties)
            {
                var att = this._propertyNameResolver.GetElasticProperty(p);
                if (att != null && att.OptOut)
                    continue;

                var propertyName = new PropertyNameResolver().Resolve(p);

                var type = GetElasticSearchType(att, p);

                if (type == null) //could not get type from attribute or infer from CLR type.
                    continue;

                jsonWriter.WritePropertyName(propertyName);
                jsonWriter.WriteStartObject();
                {
                    if (att == null) //properties that follow can not be inferred from the CLR.
                    {
                        jsonWriter.WritePropertyName("type");
                        jsonWriter.WriteValue(type);
                        //jsonWriter.WriteEnd();
                    }
                    if (att != null)
                        this.WritePropertiesFromAttribute(jsonWriter, att, propertyName, type);
                    if (type == "object" || type == "nested")
                    {

                        var deepType = p.PropertyType;
                        var deepTypeName = this.Infer.TypeName(deepType);
                        var seenTypes = new ConcurrentDictionary<Type, int>(this.SeenTypes);
                        seenTypes.AddOrUpdate(deepType, 0, (t, i) => ++i);

                        var newTypeMappingWriter = new TypeMappingWriter(deepType, deepTypeName, this._connectionSettings, MaxRecursion, seenTypes);
                        var nestedProperties = newTypeMappingWriter.MapPropertiesFromAttributes();

                        jsonWriter.WritePropertyName("properties");
                        nestedProperties.WriteTo(jsonWriter);
                    }
                }
                jsonWriter.WriteEnd();
            }
        }
Exemple #5
0
 public TypeMappingWriter(string typeName, PropertyNameResolver propertyNameResolver)
 {
     this.TypeName             = typeName;
     this.PropertyNameResolver = propertyNameResolver;
 }
 public TypeMappingWriter(string typeName, PropertyNameResolver propertyNameResolver)
     : base(typeof(T), typeName)
 {
 }