Ejemplo n.º 1
0
        private static ValidationResult CheckForDuplicates(
            LoggingSettingsEditModel model)
        {
            string previousAppName = Guid.NewGuid().ToString();
            string previousMachineName = Guid.NewGuid().ToString();

            foreach (var item in model.LoggingLevels)
            {
                if (string.Equals(item.ApplicationName, previousAppName, StringComparison.OrdinalIgnoreCase) &&
                    string.Equals(item.MachineName, previousMachineName, StringComparison.OrdinalIgnoreCase))
                {
                    return new ValidationResult(
                        string.Format(
                            "Multiple settings are specified for application '{0}' and machine '{1}'.",
                            item.ApplicationName,
                            item.MachineName));
                }

                previousAppName = item.ApplicationName;
                previousMachineName = item.MachineName;
            }

            return null;
        }
Ejemplo n.º 2
0
        private static ValidationResult CheckForEmptyApplicationsOrMachines(
            LoggingSettingsEditModel model)
        {
            if (model.LoggingLevels.Any(item =>
                string.IsNullOrWhiteSpace(item.ApplicationName) ||
                string.IsNullOrWhiteSpace(item.MachineName)))
            {
                return new ValidationResult(
                    "One or more Application or Machine values is empty.");
            }

            return null;
        }