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);
        }
        public virtual void CheckWholeObjectForCorrectnessOrThrow()
        {
            BaseValidator.CheckForNullAndEmptyOrThrow(this.EventParametersAccumulator.DefinitionId, this.GetType().Name + ".DefinitionId");

            if (this.EventParametersAccumulator.Timestamp == null)
            {
                this.Timestamp(DateTime.Now);
            }
        }
        public IBaseSessionBuilder Credentials(IWebApiCredentials credentials)
        {
            // @adk : won't be invoked more than once.
            // No validation needed.
            BaseValidator.CheckForNullAndEmptyOrThrow(credentials.Username, this.GetType().Name + ".Credentials.Username");
            BaseValidator.CheckForNullAndEmptyOrThrow(credentials.Password, this.GetType().Name + ".Credentials.Password");

            this.credentials = credentials.CredentialsShallowCopy();
            return(this);
        }
        public static SessionBuilder SessionBuilderWithHost(string instanceUrl)
        {
            BaseValidator.CheckForNullAndEmptyOrThrow(instanceUrl, typeof(SessionBuilder).Name + ".InstanceUrl");

            var result = new SessionBuilder
            {
                instanceUrl = instanceUrl
            };

            return(result);
        }
Example #5
0
        public override ICreateItemByIdRequest Build()
        {
            if (!this.IsCreateFromBranch)
            {
                BaseValidator.CheckForNullAndEmptyOrThrow(this.itemParametersAccumulator.ItemName, this.GetType().Name + ".ItemName");
            }
            BaseValidator.CheckForNullAndEmptyOrThrow(this.itemParametersAccumulator.ItemTemplate, this.GetType().Name + ".ItemTemplate");

            CreateItemByIdParameters result = new CreateItemByIdParameters(null, this.itemSourceAccumulator, this.queryParameters, this.itemParametersAccumulator, this.itemId);

            return(result);
        }
        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);
        }
Example #9
0
 public SearchRequestParametersBuilder(string keywords)
 {
     BaseValidator.CheckForNullAndEmptyOrThrow(keywords, this.GetType().Name + ".keywords");
     this.Keywords = keywords;
 }