public IEventRequestParametersBuilder <T> AddCustomValues(string customFieldName, string customFieldValue) { BaseValidator.CheckForNullAndEmptyOrThrow(customFieldName, this.GetType().Name + ".customFieldName"); BaseValidator.CheckForNullAndEmptyOrThrow(customFieldValue, this.GetType().Name + ".customFieldValue"); if (null == this.FieldsRawValuesByName) { Dictionary <string, string> newFields = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); this.FieldsRawValuesByName = newFields; } string lowerCaseField = customFieldName.ToLowerInvariant(); bool keyIsDuplicated = DuplicateEntryValidator.IsDuplicatedFieldsInTheDictionary(this.FieldsRawValuesByName, lowerCaseField); if (keyIsDuplicated) { throw new InvalidOperationException(this.GetType().Name + ".customFieldValue : duplicate fields are not allowed"); } this.FieldsRawValuesByName.Add(lowerCaseField, customFieldValue); return(this); }
private void ValidateFields(IEnumerable <string> fields) { if (DuplicateEntryValidator.IsDuplicatedFieldsInTheList(fields)) { throw new ArgumentException("AbstractGetItemUrlBuilder.GetBaseUrlForRequest() : request.QueryParameters.Fields must contain NO duplicates"); } }
private ISearchItemRequestParametersBuilder <T> AddFieldsToSort(IEnumerable <string> fields, string sortOrder) { BaseValidator.CheckNullAndThrow(fields, this.GetType().Name + ".FieldsToSort"); if (!fields.Any()) { return(this); } Func <string, bool> fieldNameValidator = fieldName => !string.IsNullOrWhiteSpace(fieldName); var validFieldsNoOrder = fields.Where(fieldNameValidator).ToList(); //adding sort order var validFields = new List <string>(); foreach (string field in validFieldsNoOrder) { validFields.Add(sortOrder + field); } IEnumerable <string> currentFields = this.sortParameters.Fields; if (null == currentFields) { currentFields = new string[0] { }; } ; int myFieldsCount = currentFields.Count(); int newFieldsCount = validFields.Count; int appendedFieldsCount = myFieldsCount + newFieldsCount; string[] newFields = new string[appendedFieldsCount]; currentFields.ToArray().CopyTo(newFields, 0); validFields.CopyTo(newFields, myFieldsCount); bool isFieldListHasDuplicates = DuplicateEntryValidator.IsDuplicatedFieldsInTheList(newFields); if (isFieldListHasDuplicates) { throw new InvalidOperationException(this.GetType().Name + ".Fields" + " : duplicate fields are not allowed"); } this.sortParameters = new SortParameters(newFields); return(this); }
public IBaseRequestParametersBuilder <T> AddFieldsToRead(IEnumerable <string> fields) { BaseValidator.CheckNullAndThrow(fields, this.GetType().Name + ".Fields"); if (!fields.Any()) { return(this); } Func <string, bool> fieldNameValidator = fieldName => !string.IsNullOrWhiteSpace(fieldName); var validFields = fields.Where(fieldNameValidator).ToList(); IEnumerable <string> currentFields = this.queryParameters.Fields; if (null == currentFields) { currentFields = new string[0] { }; } ; int myFieldsCount = currentFields.Count(); int newFieldsCount = validFields.Count; int appendedFieldsCount = myFieldsCount + newFieldsCount; string[] newFields = new string[appendedFieldsCount]; currentFields.ToArray().CopyTo(newFields, 0); validFields.CopyTo(newFields, myFieldsCount); bool isFieldListHasDuplicates = DuplicateEntryValidator.IsDuplicatedFieldsInTheList(newFields); if (isFieldListHasDuplicates) { throw new InvalidOperationException(this.GetType().Name + ".Fields" + " : duplicate fields are not allowed"); } this.queryParameters = new QueryParameters( this.queryParameters.Payload, this.queryParameters.ScopeParameters, newFields); return(this); }
public IInteractionParametersBuilder <T> AddEvents(IUTEvent utEvent) { BaseValidator.CheckNullAndThrow(utEvent, this.GetType().Name + ".utEvent"); bool isDuplicated = DuplicateEntryValidator.IsObjectInTheList(this.EventsAggregator, utEvent); if (isDuplicated) { throw new InvalidOperationException(this.GetType().Name + ".utEvent : duplicate Events are not allowed"); } this.EventsAggregator.Add(utEvent); return(this); }
public IChangeEntityParametersBuilder <T> AddFieldsRawValuesByNameToSet(string fieldName, string fieldValue) { BaseValidator.CheckForNullAndEmptyOrThrow(fieldName, this.GetType().Name + ".fieldName"); if (null == this.FieldsRawValuesByName) { Dictionary <string, string> newFields = new Dictionary <string, string>(StringComparer.Ordinal); this.FieldsRawValuesByName = newFields; } bool keyIsDuplicated = DuplicateEntryValidator.IsDuplicatedFieldsInTheDictionary(this.FieldsRawValuesByName, fieldName); if (keyIsDuplicated) { throw new InvalidOperationException(this.GetType().Name + ".FieldsRawValuesByName : duplicate fields are not allowed"); } this.FieldsRawValuesByName.Add(fieldName, fieldValue); return(this); }
public IBaseEntityRequestParametersBuilder <T> AddParametersRawValues(string parameterName, string parameterValue) { BaseValidator.CheckForNullAndEmptyOrThrow(parameterName, this.GetType().Name + ".parameterName"); BaseValidator.CheckForNullAndEmptyOrThrow(parameterValue, this.GetType().Name + ".parameterValue"); if (null == this.ParametersRawValuesByName) { Dictionary <string, string> newParameters = new Dictionary <string, string>(StringComparer.Ordinal); this.ParametersRawValuesByName = newParameters; } bool keyIsDuplicated = DuplicateEntryValidator.IsDuplicatedFieldsInTheDictionary(this.ParametersRawValuesByName, parameterName); if (keyIsDuplicated) { throw new InvalidOperationException(this.GetType().Name + ".AddParametersRawValues : duplicate fields are not allowed"); } this.ParametersRawValuesByName.Add(parameterName, parameterValue); return(this); }
public IRenderingHtmlRequestParametersBuilder <IGetRenderingHtmlRequest> AddRenderingParameterNameValue(string parameterName, string parameterValue) { BaseValidator.CheckForNullAndEmptyOrThrow(parameterName, this.GetType().Name + ".fieldName"); BaseValidator.CheckForNullAndEmptyOrThrow(parameterValue, this.GetType().Name + ".fieldValue"); if (null == this.parametersValuesByName) { Dictionary <string, string> newFields = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); this.parametersValuesByName = newFields; } bool keyIsDuplicated = DuplicateEntryValidator.IsDuplicatedFieldsInTheDictionary(this.parametersValuesByName, parameterName); if (keyIsDuplicated) { throw new InvalidOperationException(this.GetType().Name + ".ParametersValuesByName : duplicate fields are not allowed"); } this.parametersValuesByName.Add(parameterName, parameterValue); return(this); }