Esempio n. 1
0
        /// <summary>
        /// This method will call ParameterValidate and PortValidate, in most case, no need to override this, just override ParameterValidate and PortValidate
        /// </summary>
        /// <paramCollection name="message">return the combined error message</paramCollection>
        public virtual bool Validate(ref string message)
        {
            CasterLogger.Debug("Validate");

            string parameterMessage = null;
            string portMessage      = null;

            Status = CapeValidationStatus.CAPE_VALID;

            if (!ParamtersValidate(out parameterMessage))
            {
                Status = CapeValidationStatus.CAPE_INVALID;
            }

            if (!PortsValidate(out portMessage))
            {
                Status = CapeValidationStatus.CAPE_INVALID;
            }

            message = "" + parameterMessage + '\n' + portMessage;
            if (Status == CapeValidationStatus.CAPE_VALID)
            {
                CasterLogger.Debug("Validate success.");
                return(true);
            }
            else
            {
                CasterLogger.DebugFormatted("Validate fails. {0}", message);
                Debug.WriteLine("Validate fails. {0}", message);
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Validates the current value of the parameter against the
        /// specification of the parameter.
        /// </summary>
        /// <remarks>
        /// This method checks the current value of the parameter to determine if it is an allowed value. Any valid
        /// boolean value (true/false) is valid for the <see cref = "ICapeBooleanParameterSpec"/> paramaters.
        /// </remarks>
        /// <returns>
        /// True if the parameter is valid, false if not valid.
        /// </returns>
        /// <param name = "message">The message is used to return the reason that the parameter is invalid.</param>
        /// <exception cref ="ECapeUnknown">The error to be raised when other error(s),  specified for this operation, are not suitable.</exception>
        /// <exception cref = "ECapeInvalidArgument">To be used when an invalid argument value is passed.</exception>
        public override bool Validate(ref String message)
        {
            CapeValidationStatus valid = m_Parameter.ValStatus;
            bool retVal = m_Parameter.Validate(message);
            ParameterValidatedEventArgs args = new ParameterValidatedEventArgs(this.ComponentName, message, valid, m_Parameter.ValStatus);

            OnParameterValidated(args);
            return(retVal);
        }
Esempio n. 3
0
        /// <summary>
        /// Validates the current value of the parameter against the parameter's specification.
        /// </summary>
        /// <remarks>
        /// If the value of the <see cref = "RestrictedToList">RestrictedToList</see>
        /// public is set to <c>true</c>, the parameter is valid only if the current value
        /// is included in the <see cref = "OptionList">OptionList</see>. If the
        /// value of <see cref = "RestrictedToList">RestrictedToList</see> public is <c>false</c>
        /// any valid String is a valid value for the parameter.
        /// </remarks>
        /// <returns>True if the string argument is valid, false if it is not.</returns>
        /// <param name = "message">Reference to a string that will conain a message regarding the validation of the parameter.</param>
        /// <exception cref ="ECapeUnknown">The error to be raised when other error(s),  specified for this operation, are not suitable.</exception>
        /// <exception cref = "ECapeInvalidArgument">To be used when an invalid argument value is passed, for example, an unrecognised Compound identifier or UNDEFINED for the props argument.</exception>
        public override bool Validate(ref String message)
        {
            ParameterValidatedEventArgs args;
            CapeValidationStatus        valid = m_parameter.ValStatus;
            bool retVal = m_parameter.Validate(message);

            args = new ParameterValidatedEventArgs(this.ComponentName, message, valid, m_parameter.ValStatus);
            NotifyPropertyChanged("ValStatus");
            OnParameterValidated(args);
            return(true);
        }
        public static CapeOpenValidationStatus Map(CapeValidationStatus status)
        {
            switch (status)
            {
            case CapeValidationStatus.CAPE_VALID:
                return(CapeOpenValidationStatus.Valid);

            case CapeValidationStatus.CAPE_INVALID:
                return(CapeOpenValidationStatus.Invalid);

            case CapeValidationStatus.CAPE_NOT_VALIDATED:
                return(CapeOpenValidationStatus.NotYetValidated);

            default:
                throw new CapeOpenException();
            }
        }