Ejemplo n.º 1
0
        private TisValidationMethodResult ExecuteValidationMethod(
            TisValidationMethod validationMethod,
            object validationsSource,
            object validationsTarget,
            List <ITisValidationContext> validationContexts)
        {
            TisValidationMethodDetailedInfo detailedInfo = null;
            ValidationStatus validationStatus            = ValidationStatus.Unknown;

            object[] validationMethodParameters = null;

            try
            {
                validationMethodParameters =
                    ObtainValidationMethodParameters(validationMethod, validationsTarget, validationContexts);

                if (validationMethodParameters == null)
                {
                    // Default method parameters
                    validationMethodParameters =
                        new object[validationMethod.MethodSignature.Params.Length];
                }

                bool validParams =
                    ValidateMethodParameters(validationMethod.MethodSignature, validationMethodParameters);

                if (validParams)
                {
                    object methodReturn =
                        validationMethod.Method.Invoke(validationsSource, validationMethodParameters);

                    if (methodReturn is ValidationStatus)
                    {
                        validationStatus = (ValidationStatus)methodReturn;
                    }
                    else
                    {
                        if (methodReturn is TisValidationStatusProvider)
                        {
                            validationStatus = (methodReturn as TisValidationStatusProvider).Status;
                            detailedInfo     = (methodReturn as TisValidationStatusProvider).DetailedInfo;
                        }
                        else
                        {
                            Log.WriteWarning("Validation method [{0}] does not return validation status ", validationMethod.Name);
                        }
                    }
                }
                else
                {
                    Log.WriteError("Validation method [{0}] has invalid parameter(s)", validationMethod.Name);
                }
            }
            catch (Exception exc)
            {
                Log.WriteException(exc);
            }

            return(new TisValidationMethodResult(validationStatus, validationMethodParameters, detailedInfo));
        }
Ejemplo n.º 2
0
 public TisValidationMethodResult(
     ValidationStatus status,
     object[] parameters,
     TisValidationMethodDetailedInfo detailedInfo)
 {
     m_status       = status;
     m_parameters   = parameters;
     m_detailedInfo = detailedInfo;
 }
Ejemplo n.º 3
0
        public TisValidationStatusProvider(
            ValidationStatus validationStatus,
            string message,
            string details,
            ValidationShowDetailedInfo showDetailedInfo)
        {
            m_status = validationStatus;

            m_detailedInfo =
                new TisValidationMethodDetailedInfo(message, details, showDetailedInfo);
        }