Exemplo n.º 1
0
        /// <summary>
        /// Defines a parameter
        /// </summary>
        /// <param name="parameter">The parameter information</param>
        private void DefineParameter
        (
            WebApiPluginParameterInfo parameter
        )
        {
            Validate.IsNotNull(parameter);

            var name = parameter.Name;

            if (_actionParameters == null)
            {
                _actionParameters = new List <WebApiPluginParameterInfo>();
            }

            var matchFound = this.Parameters.Any
                             (
                m => m.Name.ToLower() == name.ToLower()
                             );

            if (matchFound)
            {
                throw new InvalidOperationException
                      (
                          $"A parameter with the name '{name}' has already been defined."
                      );
            }

            _actionParameters.Add(parameter);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Defines a parameter using the default type (string)
        /// </summary>
        /// <param name="name">The parameter name</param>
        /// <param name="allowNull">True, if null values are allowed</param>
        protected void DefineParameter(string name, bool allowNull = true)
        {
            Validate.IsNotEmpty(name);

            var parameter = new WebApiPluginParameterInfo(name, typeof(string), null, allowNull);

            DefineParameter(parameter);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Defines a parameter using the details specified
        /// </summary>
        /// <param name="name">The parameter name</param>
        /// <param name="valueType">The parameter value type</param>
        /// <param name="defaultValue">The default value</param>
        /// <param name="allowNull">True, if null is allowed</param>
        protected void DefineParameter(string name, Type valueType, object defaultValue, bool allowNull)
        {
            Validate.IsNotEmpty(name);
            Validate.IsNotNull(valueType);

            var parameter = new WebApiPluginParameterInfo(name, valueType, defaultValue, allowNull);

            DefineParameter(parameter);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Defines a parameter using the details specified
        /// </summary>
        /// <param name="name">The parameter name</param>
        /// <param name="valueType">The parameter value type</param>
        protected void DefineParameter(string name, Type valueType)
        {
            Validate.IsNotEmpty(name);
            Validate.IsNotNull(valueType);

            var parameter = new WebApiPluginParameterInfo(name, valueType, null, true);

            DefineParameter(parameter);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Defines a parameter
        /// </summary>
        /// <param name="parameter">The parameter information</param>
        private void DefineParameter(WebApiPluginParameterInfo parameter)
        {
            Validate.IsNotNull(parameter);

            var name = parameter.Name;

            if (_actionParameters == null)
            {
                _actionParameters = new List <WebApiPluginParameterInfo>();
            }

            var matchFound = Parameters.Any(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

            if (matchFound)
            {
                throw new InvalidOperationException
                      (
                          $"A parameter with the name '{name}' has already been defined."
                      );
            }

            _actionParameters.Add(parameter);
        }