/// <summary> /// /// </summary> /// <param name="field">If this is blank, then the title field is used as the default.</param> /// <param name="value"></param> /// <returns></returns> public void AppendField(string fieldName,string value,FieldComparison fieldType) { if (string.IsNullOrEmpty(fieldName)) fieldName = "Title"; Field field = null; string key = fieldName + _nextFieldIsNot; if (_queryStack.Count > 0) { field = _queryStack.Peek() as Field; if (field != null) { if (!_fieldLookup.ContainsKey(key) && field.ToString() != "") { _queryStack.Push("AND"); } } } if (_fieldLookup.ContainsKey(key)) { // Combine repeated field definitions into a single = (instead of repeating them with ANDs) _fieldLookup[key].Value += " " + value; } else { switch (fieldType) { case FieldComparison.User: field = new UserField(); break; case FieldComparison.Date: field = new DateField(); break; case FieldComparison.Project: field = new ProjectField(); break; case FieldComparison.Contains: field = new ContainsField(); break; case FieldComparison.ExactMatch: default: field = new Field(); break; } field.ColumnName = ToColumnName(fieldName); field.ParameterName = fieldName; field.Value = value; field.IsNot = _nextFieldIsNot; _queryStack.Push(field); _fieldLookup.Add(key, field); } // reset for future fields _nextFieldIsNot = false; }
/// <summary> /// /// </summary> /// <param name="field">If this is blank, then the title field is used as the default.</param> /// <param name="value"></param> /// <returns></returns> public void AppendField(string fieldName, string value, FieldComparison fieldType) { if (string.IsNullOrEmpty(fieldName)) { fieldName = "Title"; } Field field = null; string key = fieldName + _nextFieldIsNot; if (_queryStack.Count > 0) { field = _queryStack.Peek() as Field; if (field != null) { if (!_fieldLookup.ContainsKey(key) && field.ToString() != "") { _queryStack.Push("AND"); } } } if (_fieldLookup.ContainsKey(key)) { // Combine repeated field definitions into a single = (instead of repeating them with ANDs) _fieldLookup[key].Value += " " + value; } else { switch (fieldType) { case FieldComparison.User: field = new UserField(); break; case FieldComparison.Date: field = new DateField(); break; case FieldComparison.Project: field = new ProjectField(); break; case FieldComparison.Contains: field = new ContainsField(); break; case FieldComparison.ExactMatch: default: field = new Field(); break; } field.ColumnName = ToColumnName(fieldName); field.ParameterName = fieldName; field.Value = value; field.IsNot = _nextFieldIsNot; _queryStack.Push(field); _fieldLookup.Add(key, field); } // reset for future fields _nextFieldIsNot = false; }