示例#1
0
        public string Field(Field field)
        {
            if (field.IsConditionless())
            {
                return(null);
            }

            var name = !field.Name.IsNullOrEmpty()
                                ? field.Name
                                : field.Expression != null
                                        ? this.FieldResolver.Resolve(field.Expression)
                                        : field.Property != null
                                                ? this.FieldResolver.Resolve(field.Property)
                                                : null;

            if (name == null)
            {
                throw new ArgumentException("Could not resolve a field name");
            }

            if (field != null && field.Boost.HasValue)
            {
                name += "^" + field.Boost.Value.ToString(CultureInfo.InvariantCulture);
            }

            return(name);
        }
示例#2
0
        private string ResolveFieldName(Field field)
        {
            if (field.IsConditionless())
            {
                return(null);
            }
            if (!field.Name.IsNullOrEmpty())
            {
                return(field.Name);
            }
            if (field.Expression != null && !field.CachableExpression)
            {
                return(this.Resolve(field.Expression, field.Property));
            }

            string fieldName;

            if (this.Fields.TryGetValue(field, out fieldName))
            {
                return(fieldName);
            }

            fieldName = this.Resolve(field.Expression, field.Property);
            this.Fields.TryAdd(field, fieldName);
            return(fieldName);
        }
示例#3
0
        public string Resolve(Field field)
        {
            if (field.IsConditionless())
            {
                return(null);
            }
            if (!field.Name.IsNullOrEmpty())
            {
                return(field.Name);
            }
            string f;

            if (this.Fields.TryGetValue(field, out f))
            {
                return(f);
            }
            f = this.Resolve(field.Expression, field.Property);
            this.Fields.TryAdd(field, f);
            return(f);
        }