public override void Validate()
        {
            if (Errors == null)
            {
                Errors = new List <IActionableErrorInfo>();
            }
            Errors.Clear();

            Errors = Regions.SelectMany(a => a.Errors).Select(a => new ActionableErrorInfo(new ErrorInfo {
                Message = a, ErrorType = ErrorType.Critical
            }, () => { }) as IActionableErrorInfo).ToList();
            if (SourceRegion.Errors.Count > 0)
            {
                foreach (var designValidationError in SourceRegion.Errors)
                {
                    DesignValidationErrors.Add(new ErrorInfo {
                        ErrorType = ErrorType.Critical, Message = designValidationError
                    });
                }
            }
            if (Errors.Count <= 0)
            {
                ClearValidationMemoWithNoFoundError();
            }
            UpdateWorstError();
            InitializeProperties();
        }
Exemple #2
0
        void CheckForRequiredMapping()
        {
            if (DataMappingViewModel != null && DataMappingViewModel.Inputs.Any(c => c.Required && String.IsNullOrEmpty(c.MapsTo)))
            {
                if (DesignValidationErrors.All(c => c.FixType != FixType.IsRequiredChanged))
                {
                    var listToRemove = DesignValidationErrors.Where(c => c.FixType == FixType.None && c.ErrorType == ErrorType.None).ToList();

                    foreach (var errorInfo in listToRemove)
                    {
                        DesignValidationErrors.Remove(errorInfo);
                    }

                    var mappingIsRequiredMessage = CreateMappingIsRequiredMessage();
                    DesignValidationErrors.Add(mappingIsRequiredMessage);
                    RootModel.AddError(mappingIsRequiredMessage);
                }
                UpdateWorstError();
                return;
            }

            if (DesignValidationErrors.Any(c => c.FixType == FixType.IsRequiredChanged))
            {
                var listToRemove = DesignValidationErrors.Where(c => c.FixType == FixType.IsRequiredChanged).ToList();

                foreach (var errorInfo in listToRemove)
                {
                    DesignValidationErrors.Remove(errorInfo);
                    RootModel.RemoveError(errorInfo);
                }
                UpdateWorstError();
            }
        }
 void UpdateDesignValidationErrors(IEnumerable <IErrorInfo> errors)
 {
     DesignValidationErrors.Clear();
     foreach (var error in errors)
     {
         DesignValidationErrors.Add(error);
     }
     UpdateWorstError();
 }
 public void UpdateDesignValidationErrors(IEnumerable <IErrorInfo> errors)
 {
     DesignValidationErrors.Clear();
     _serviceDesignerViewModel.RootModel.ClearErrors();
     foreach (var error in errors)
     {
         DesignValidationErrors.Add(error);
         _serviceDesignerViewModel.RootModel.AddError(error);
     }
     UpdateWorstError();
 }
        void UpdateWorstError()
        {
            if (DesignValidationErrors.Count == 0)
            {
                DesignValidationErrors.Add(NoError);
            }

            IErrorInfo[] worstError = { DesignValidationErrors[0] };

            foreach (var error in DesignValidationErrors.Where(error => error.ErrorType > worstError[0].ErrorType))
            {
                worstError[0] = error;
                if (error.ErrorType == ErrorType.Critical)
                {
                    break;
                }
            }
            WorstDesignError = worstError[0];
        }
 public override void Validate()
 {
     if (Errors == null)
     {
         Errors = new List <IActionableErrorInfo>();
     }
     Errors.Clear();
     if (SourceRegion.Errors.Count > 0)
     {
         foreach (var designValidationError in SourceRegion.Errors)
         {
             DesignValidationErrors.Add(new ErrorInfo {
                 ErrorType = ErrorType.Critical, Message = designValidationError
             });
         }
     }
     if (Errors.Count <= 0)
     {
         ClearValidationMemoWithNoFoundError();
     }
     UpdateWorstError();
     InitializeProperties();
 }
        public void UpdateWorstError()
        {
            if (DesignValidationErrors.Count == 0)
            {
                DesignValidationErrors.Add(NoError);
                if (!_serviceDesignerViewModel.RootModel.HasErrors)
                {
                    _serviceDesignerViewModel.RootModel.IsValid = true;
                }
            }

            IErrorInfo[] worstError = { DesignValidationErrors[0] };

            foreach (var error in DesignValidationErrors.Where(error => error.ErrorType > worstError[0].ErrorType))
            {
                worstError[0] = error;
                if (error.ErrorType == ErrorType.Critical)
                {
                    break;
                }
            }
            WorstDesignError = worstError[0];
        }