예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchConfigurationModel" /> class.
 /// </summary>
 /// <param name="fieldId">Contains the field identity used for filtering.</param>
 /// <param name="displayName">Contains the user interface field display name.</param>
 /// <param name="type">Contains the data type of the field.</param>
 /// <param name="validValues">Contains an optional list of valid values for the field.</param>
 /// <param name="compareExists">Contains a value indicating whether this is an existence comparison (not null).</param>
 /// <param name="overrideOperators">Contains an optional list of valid operators for the field.</param>
 public SearchConfigurationModel(string fieldId, string displayName, SearchConfigurationDataType type = SearchConfigurationDataType.String, List <KeyValuePair <string, string> > validValues = null, bool compareExists = false, Dictionary <SearchExpressionOperator, string> overrideOperators = null)
 {
     this.FieldId       = fieldId;
     this.DisplayName   = displayName;
     this.DataType      = type;
     this.CompareExists = compareExists;
     this.Operators     = overrideOperators?.Select(d => new KeyValuePair <SearchExpressionOperator, string>(d.Key, d.Value)).ToList() ?? SearchConfigurationDefaults.TypeOperators(type);
     this.ValidValues   = validValues ?? new List <KeyValuePair <string, string> >();
 }
예제 #2
0
        /// <summary>
        /// This method is used to build a list of search expression operators based on the specified type.
        /// </summary>
        /// <param name="type">Contains the type to build expression operators for.</param>
        /// <returns>Returns a list of expression operators.</returns>
        public static List <KeyValuePair <SearchExpressionOperator, string> > TypeOperators(SearchConfigurationDataType type)
        {
            Dictionary <SearchExpressionOperator, string> result;

            switch (type)
            {
            case SearchConfigurationDataType.Long:
                result = LongOperators;
                break;

            case SearchConfigurationDataType.SimplifiedLong:
                result = SimplifiedLongOperators;
                break;

            case SearchConfigurationDataType.Int:
                result = IntegerOperators;
                break;

            case SearchConfigurationDataType.SimplifiedInt:
                result = SimplifiedIntegerOperators;
                break;

            case SearchConfigurationDataType.DateTime:
                result = DateTimeOperators;
                break;

            case SearchConfigurationDataType.Boolean:
                result = BooleanOperators;
                break;

            default:
                result = StringOperators;
                break;
            }

            return(result.Select(d => new KeyValuePair <SearchExpressionOperator, string>(d.Key, d.Value)).ToList());
        }