Esempio n. 1
0
        public ValidationException(List <ValidationFailure> failures)
            : this()
        {
            var propertyNames = failures
                                .Select(e => e.PropertyName)
                                .Distinct();

            foreach (var propertyName in propertyNames)
            {
                var propertyFailures = failures
                                       .Where(e => e.PropertyName == propertyName)
                                       .Select(e => e.ErrorMessage)
                                       .ToArray();

                Failures.Add(propertyName, propertyFailures);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Attempt each operation.
        /// Any exceptions from failures are caught and stored for later.
        /// </summary>
        /// <param name="actions">The list of actions.</param>
        /// <returns></returns>
        public SafeActions Attempt(IEnumerable <Action> actions)
        {
            foreach (Action action in actions)
            {
                try
                {
                    action();
                }
                catch (Exception e)
                {
                    Failures.Add(e);
                    FailureHandler(e);
                }
            }

            return(this);
        }
Esempio n. 3
0
        public List <Type> GetDynamicTypes()
        {
            List <Type> dynamicTypes = new List <Type>();

            YamlFiles.Each(new { List = dynamicTypes }, (ctx, yf) =>
            {
                try
                {
                    ctx.List.AddRange(yf.DynamicTypes);
                }
                catch (Exception ex)
                {
                    FireEvent(YamlDeserializationFailed, new YamlEventArgs {
                        Schema = this, Files = this.Files, CurrentFile = yf, Exception = ex
                    });
                    Failures.Add(new YamlDeserializationFailure(yf, ex));
                }
            });

            return(dynamicTypes);
        }
Esempio n. 4
0
        public void Install()
        {
            // Record that we have attempted an install.
            Attempted = true;

            // Can this be installed at this point?
            if (CanInstall)
            {
                // Possibly need to recreate the installer at this point.
                Installer = new Installer(Installer.TempInstallFolder, ModuleManifestName(Installer.TempInstallFolder), Globals.ApplicationMapPath, true);

                // Is the installer valid?
                if (Installer.IsValid)
                {
                    // Already installed?
                    if (Installer.InstallerInfo.Installed)
                    {
                        // Yes, make a repair install.
                        Installer.InstallerInfo.RepairInstall = true;
                    }

                    // Install.
                    Installer.Install();

                    // Did the package install successfully?
                    Success = Installer.IsValid;
                }

                // Record failures.
                foreach (LogEntry log in Installer.InstallerInfo.Log.Logs)
                {
                    if (log.Type.Equals(LogType.Failure))
                    {
                        string failure = log.ToString();

                        Failures.Add(failure);
                    }
                }
            }
        }
        public ValidationException(List <ValidationFailure> failures)
            : this()
        {
            var sb = new StringBuilder();

            var propertyNames = failures
                                .Select(e => e.PropertyName)
                                .Distinct();

            foreach (var propertyName in propertyNames)
            {
                var propertyFailures = failures
                                       .Where(e => e.PropertyName == propertyName)
                                       .Select(e => e.ErrorMessage)
                                       .ToArray();

                Failures.Add(propertyName, propertyFailures);
                sb.Append(string.Join(" ", propertyFailures));
            }

            AllFailuresMessage = sb.ToString();
        }
Esempio n. 6
0
        private void AddInMatrices(int row, int col, string buildingShort, int buildingIndex)
        {
            var temp = _matrixType[row, col].FirstOrDefault(s => s.Contains("@"));

            bool fail = !(_matrixType[row, col].Count == 0 ||
                          (temp != null && temp.Length <= 3));

            _matrixType[row, col].Add(buildingShort);
            _matrixIndex[row, col].Add(buildingIndex);
            if (fail)
            {
                var key = "" + row + "," + col;

                if (!Failures.ContainsKey(key))
                {
                    Failures.Add(key, string.Join("", _matrixType[row, col].ToArray()));
                }
                else
                {
                    Failures[key] += buildingShort;
                }
            }
        }
Esempio n. 7
0
 private R(E error)
 {
     IsSuccess = false;
     Failures.Add(error);
 }
Esempio n. 8
0
 public ValidationException(List <IdentityError> failures)
     : this()
 {
     Failures.Add("general", failures.Select(x => x.Description).ToArray());
 }
 public AppSubscriptionException(string failure)
     : base(failure)
 {
     Failures.Add(failure);
 }
Esempio n. 10
0
 public ValidationException(string key, string[] message) : this()
 {
     Failures.Add(key, message);
 }
Esempio n. 11
0
 public ValidationException(string key, string message) : this()
 {
     Failures.Add(key, new string[1] {
         message
     });
 }
Esempio n. 12
0
 public ValidationException(string propertyName, string errorMessage)
     : this()
 {
     Failures.Add(propertyName, new[] { errorMessage });
 }
Esempio n. 13
0
 public BadRequestException(string message)
     : this()
 {
     Failures.Add("message", new string[] { message });
 }
Esempio n. 14
0
 public AppBusinessException(string failure)
     : base(failure)
 {
     Failures.Add(failure);
 }