Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="criterionName"></param>
 /// <param name="level"></param>
 /// <param name="regularExpression"></param>
 /// <param name="caseSensitive"></param>
 /// <param name="trim"></param>
 /// <param name="customMessages"></param>
 public MyRegularExpressionCriterion(string criterionName, ValidationLevel level, Regex regularExpression,
                                     bool caseSensitive, bool trim,
                                     CustomValidationMessages customMessages)
     : base(criterionName, level, caseSensitive, trim, customMessages)
 {
     this.m_regex = regularExpression;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Checks the specified ADX file for errors.
        /// </summary>
        /// <param name="fileName">Name of the ADX file.</param>
        /// <param name="level">The validation level.</param>
        /// <param name="schemasDirectory">The directory for the ADX schemas.</param>
        public void Check(String fileName, ValidationLevel level, String schemasDirectory)
        {
            // No validation required ?
            if (level == ValidationLevel.None)
            {
                return;
            }

            // Validate according to the ADX schema
            ValidateSchema validateSchema = new ValidateSchema();

            validateSchema.Check(fileName, schemasDirectory);
            this.AddRange(validateSchema);

            if (level == ValidationLevel.SchemaOnly)
            {
                return;
            }

            // Validate a laboratory assay export
            if (level == ValidationLevel.LaboratoryExport)
            {
                ValidateLaboratoryExport validateLab = new ValidateLaboratoryExport();

                validateLab.Check(fileName);

                this.AddRange(validateLab); // Report any results from this validation
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="criterionName"></param>
 /// <param name="level"></param>
 /// <param name="regularExpression"></param>
 /// <param name="caseSensitive"></param>
 /// <param name="trim"></param>
 /// <param name="customMessages"></param>
 public MyRegularExpressionCriterion(string criterionName, ValidationLevel level, Regex regularExpression,
                                     bool caseSensitive, bool trim,
                                     CustomValidationMessages customMessages)
     : base(criterionName, level, caseSensitive, trim, customMessages)
 {
     this.m_regex = regularExpression;
 }
Exemplo n.º 4
0
 private ValidationMessage(string errorCode, ValidationLevel level, string message, string propertyName)
 {
     ErrorCode    = errorCode;
     Level        = level;
     Message      = message ?? throw new ArgumentNullException(nameof(message));
     PropertyName = propertyName ?? throw new ArgumentNullException(nameof(propertyName));
 }
Exemplo n.º 5
0
 public ValidationMessage(PartElement sourceElement, string messageCode, ValidationLevel level, params object[] arguments)
 {
     Code          = messageCode;
     Level         = level;
     SourceElement = sourceElement;
     if (sourceElement is PartSurface)
     {
         SourceKey = "SURFACE";
     }
     else if (sourceElement is SurfaceComponent)
     {
         SourceKey = "COMPONENT";
     }
     else if (sourceElement is PartProperties)
     {
         SourceKey = "PART";
     }
     else if (sourceElement is PartBone)
     {
         SourceKey = "BONE";
     }
     else
     {
         SourceKey = "PROJECT";
     }
     MessageArguments = arguments;
 }
Exemplo n.º 6
0
 public ValidationMessage(string source, string code, ValidationLevel level, params object[] arguments)
 {
     SourceKey        = source;
     Code             = code;
     Level            = level;
     MessageArguments = arguments;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="criterionName"></param>
 /// <param name="level"></param>
 /// <param name="caseSensitive"></param>
 /// <param name="trim"></param>
 /// <param name="customMessages"></param>
 /// <param name="v1"></param>
 /// <param name="v2"></param>
 public AndValidCriterion(string criterionName, ValidationLevel level, bool caseSensitive, bool trim, CustomValidationMessages customMessages,
     ValidationCriterion v1, ValidationCriterion v2)
     : base(criterionName, level, caseSensitive, trim, customMessages)
 {
     this.m_criterion1 = v1;
     this.m_criterion2 = v2;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="criterionName"></param>
 /// <param name="level"></param>
 /// <param name="caseSensitive"></param>
 /// <param name="trim"></param>
 /// <param name="customMessages"></param>
 /// <param name="v1"></param>
 /// <param name="v2"></param>
 public AndValidCriterion(string criterionName, ValidationLevel level, bool caseSensitive, bool trim, CustomValidationMessages customMessages,
                          ValidationCriterion v1, ValidationCriterion v2)
     : base(criterionName, level, caseSensitive, trim, customMessages)
 {
     this.m_criterion1 = v1;
     this.m_criterion2 = v2;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MergedValidationMessage" /> class.
        /// </summary>
        /// <param name="validationLevel">The validation level.</param>
        /// <param name="messages">The messages.</param>
        public MergedValidationMessage(ValidationLevel validationLevel, IEnumerable <string> messages)
            : this()
        {
            messages.CannotBeNull();

            this.ValidationLevel = validationLevel;
            this.Message         = GetMergedMessages == null?DefaultMergeMessages(messages) : GetMergedMessages(messages) ?? DefaultMergeMessages(messages);
        }
Exemplo n.º 10
0
        public static List <ValidationResult> Validate(string fileName, ValidationLevel level, string schemasDirectory)
        {
            DocumentValidation validator = new DocumentValidation();

            validator.Check(fileName, level, schemasDirectory);

            return(validator);
        }
Exemplo n.º 11
0
 public ValidationRow(ValidationLevel level, Point tileLocation,
                      string message, Action <MapManager, ValidationRow, StringBuilder>?fixAction)
 {
     Level        = level;
     TileLocation = tileLocation;
     Message      = message;
     FixAction    = fixAction;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GroupValidationAttribute"/> class.
 /// </summary>
 /// <param name="validationLevel">
 /// The validation level (Error, Warning).
 /// </param>
 /// <param name="useInImplicitValidation">
 /// Indicates if the validation of this attribute will be triggered by a property change.
 /// </param>
 /// <param name="showMessageOnProperty">
 /// Indicates whether the validation message will be shown on the property at the UI.
 /// </param>
 /// <param name="showMessageInSummary">
 /// Indicates whether the validation message will be shown in the validation summary at the UI.
 /// </param>
 protected GroupValidationAttribute(
     ValidationLevel validationLevel = ValidationLevel.Error,
     bool useInImplicitValidation = true,
     bool showMessageOnProperty = true,
     bool showMessageInSummary = true)
     : base(validationLevel, useInImplicitValidation, showMessageOnProperty, showMessageInSummary)
 {
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidationEntry"/> struct.
 /// </summary>
 /// <param name="level">The validation level (error, warning or information).</param>
 /// <param name="description">The entry description.</param>
 /// <param name="type">The type of entry.</param>
 /// <param name="code">A code representing the entry.</param>
 /// <param name="severity">The severity of the entry (error only).</param>
 public ValidationEntry(ValidationLevel level, string description, string type = null, long?code = null, int?severity = null)
 {
     this.level       = level;
     this.description = description;
     this.type        = type;
     this.code        = code;
     this.severity    = severity;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="criterionName"></param>
 /// <param name="level"></param>
 /// <param name="script"></param>
 /// <param name="param"></param>
 /// <param name="caseSensitive"></param>
 /// <param name="trim"></param>
 /// <param name="customMessages"></param>
 public ScriptCriterion(string criterionName, ValidationLevel level, string script, Dictionary <string, object> param,
                        bool caseSensitive, bool trim,
                        CustomValidationMessages customMessages)
     : base(criterionName, level, caseSensitive, trim, customMessages)
 {
     this.m_script = script;
     this.m_param  = param;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="criterionName"></param>
 /// <param name="level"></param>
 /// <param name="script"></param>
 /// <param name="param"></param>
 /// <param name="caseSensitive"></param>
 /// <param name="trim"></param>
 /// <param name="customMessages"></param>
 public ScriptCriterion(string criterionName, ValidationLevel level, string script,  Dictionary<string, object> param,
                                     bool caseSensitive, bool trim,
                                     CustomValidationMessages customMessages)
     : base(criterionName, level, caseSensitive, trim, customMessages)
 {
     this.m_script = script;
     this.m_param = param;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidationMessage"/> class.
 /// </summary>
 /// <param name="validationLevel">
 /// The validation level (Error, Warning).
 /// </param>
 /// <param name="messageText">
 /// Validation message text.
 /// </param>
 /// <param name="validationMessageKind">
 /// The validation message kind which indicates what kind of validation 
 /// has been performed (property or entity based).
 /// </param>
 public ValidationMessage(ValidationLevel validationLevel, string messageText, ValidationMessageKind validationMessageKind)
 {
     this.ValidationLevel = validationLevel;
     this.MessageText = messageText;
     this.ValidationMessageKind = validationMessageKind;
     this.ShowMessageOnProperty = true;
     this.ShowMessageInSummary = true;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncGroupValidationAttribute"/> class by using the function that enables access to validation resources.
 /// </summary>
 /// <param name="errorMessageAccessor">
 /// Function that enables access to validation resources.
 /// </param>
 /// <param name="validationLevel">
 /// The validation level (Error, Warning).
 /// </param>
 /// <param name="useInImplicitValidation">
 /// Indicates if the validation of this attribute will be triggered by a property change.
 /// </param>
 /// <param name="showMessageOnProperty">
 /// Indicates whether the validation message will be shown on the property at the UI.
 /// </param>
 /// <param name="showMessageInSummary">
 /// Indicates whether the validation message will be shown in the validation summary at the UI.
 /// </param>
 protected AsyncGroupValidationAttribute(
     Func<string> errorMessageAccessor,
     ValidationLevel validationLevel = ValidationLevel.Error,
     bool useInImplicitValidation = true,
     bool showMessageOnProperty = true,
     bool showMessageInSummary = true)
     : base(errorMessageAccessor, validationLevel, useInImplicitValidation, showMessageOnProperty, showMessageInSummary)
 {
 }
Exemplo n.º 18
0
 public ValidationIssue(
     ValidationLevel level,
     string description,
     params string[] stack)
 {
     this.Level       = level;
     this.Description = description;
     this.Stack       = stack;
 }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ValidationLevel rate      = (ValidationLevel)value;
            string          imagePath = rate == ValidationLevel.Success ? string.Empty :
                                        rate == ValidationLevel.Error ? "../Resources/CriticalError.png"
                : "../Resources/Warning.png";

            return(string.IsNullOrEmpty(imagePath) ? null : new BitmapImage(new Uri(imagePath, UriKind.Relative)));
        }
Exemplo n.º 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ValidationResult"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="level">The level.</param>
        /// <param name="message">The message.</param>
        /// <param name="args">An <see cref="Object"/> array containing zero or more objects to format.</param>
        public ValidationResult(object source, ValidationLevel level, string message, params object[] args)
            : this(source, level)
        {
            if (string.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException("message");
            }

            this.message = string.Format(message, args);
        }
Exemplo n.º 21
0
        private ValidationResult(object source, ValidationLevel level)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            this.source = source;
            this.level  = level;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncValidationAttribute"/> class.
 /// </summary>
 /// <param name="validationLevel">
 /// The validation level (Error, Warning).
 /// </param>
 /// <param name="useInImplicitValidation">
 /// Indicates if the validation of this attribute will be triggered by a property change.
 /// </param>
 /// <param name="showMessageOnProperty">
 /// Indicates whether the validation message will be shown on the property at the UI.
 /// </param>
 /// <param name="showMessageInSummary">
 /// Indicates whether the validation message will be shown in the validation summary at the UI.
 /// </param>
 protected AsyncValidationAttribute(
     ValidationLevel validationLevel = ValidationLevel.Error,
     bool useInImplicitValidation = true,
     bool showMessageOnProperty = true,
     bool showMessageInSummary = true)
 {
     this.ValidationLevel = validationLevel;
     this.UseInImplicitValidation = useInImplicitValidation;
     this.ShowMessageOnProperty = showMessageOnProperty;
     this.ShowMessageInSummary = showMessageInSummary;
 }
Exemplo n.º 23
0
        public DomainValidationMessage(ValidationLevel level, string property, string message, params object[] messageParams)
        {
            if (messageParams.Length > 0)
            {
                message = string.Format(message, messageParams);
            }

            this.Message  = message;
            this.Level    = level;
            this.Property = property;
        }
Exemplo n.º 24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ValidationResult"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="level">The level.</param>
        /// <param name="message">The message.</param>
        public ValidationResult(object source, ValidationLevel level, Mutable <string> message)
            : this(source, level)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            this.mutableMessage = message;
            this.mutableMessage.ValueChanged += this.OnMessageChanged;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AsyncValidationAttribute"/> class by using the function that enables access to validation resources.
        /// </summary>
        /// <param name="errorMessageAccessor">
        /// Function that enables access to validation message resources.
        /// </param>
        /// <param name="validationLevel">
        /// The validation level (Error, Warning).
        /// </param>
        /// <param name="useInImplicitValidation">
        /// Indicates if the validation of this attribute will be triggered by a property change.
        /// </param>
        /// <param name="showMessageOnProperty">
        /// Indicates whether the validation message will be shown on the property at the UI.
        /// </param>
        /// <param name="showMessageInSummary">
        /// Indicates whether the validation message will be shown in the validation summary at the UI.
        /// </param>
        protected AsyncValidationAttribute(
            Func<string> errorMessageAccessor,
            ValidationLevel validationLevel = ValidationLevel.Error,
            bool useInImplicitValidation = true,
            bool showMessageOnProperty = true,
            bool showMessageInSummary = true)
            : this(validationLevel, useInImplicitValidation, showMessageOnProperty, showMessageInSummary)
        {
            Guard.AssertNotNull(errorMessageAccessor, "errorMessageAccessor");

            this.errorMessageAccessor = errorMessageAccessor;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidationMessage"/> class.
 /// </summary>
 /// <param name="validationLevel">
 /// The validation level (Error, Warning).
 /// </param>
 /// <param name="messageText">
 /// Validation message text.
 /// </param>
 /// <param name="showMessageOnProperty">
 /// Indicates whether the validation message will be shown on the property at the UI.
 /// </param>
 /// <param name="showMessageInSummary">
 /// Indicates whether the validation message will be shown in the validation summary at the UI.
 /// </param>
 /// <param name="validationMessageKind">
 /// The validation message kind which indicates what kind of validation 
 /// has been performed (property or entity based).
 /// </param>
 public ValidationMessage(
     ValidationLevel validationLevel,
     string messageText,
     bool showMessageOnProperty = true,
     bool showMessageInSummary = true,
     ValidationMessageKind? validationMessageKind = null)
 {
     this.ValidationLevel = validationLevel;
     this.MessageText = messageText;
     this.ShowMessageOnProperty = showMessageOnProperty;
     this.ShowMessageInSummary = showMessageInSummary;
     this.ValidationMessageKind = validationMessageKind;
 }
Exemplo n.º 27
0
 public ValidationMessage(string message, ValidationLevel level, params string[] members)
 {
     if (members == null || members.Length == 0)
     {
         Members = EmptyMembersCollection;
     }
     else
     {
         Members = new ReadOnlyCollection <string>(members.ToArray());
     }
     Message = message ?? level.ToString();
     Level   = level;
 }
Exemplo n.º 28
0
        /// <summary>
        /// Prüft alle Commands und gibt den kritischsten ValidationLevel aus
        /// </summary>
        /// <returns></returns>
        internal ValidationLevel getValidationLevel()
        {
            ValidationLevel lvl = ValidationLevel.Ok;

            this.commands.ForEach(delegate(Commando cmd)
            {
                if (cmd.ValidationState > lvl)
                {
                    lvl = cmd.ValidationState;
                }
            });
            return(lvl);
        }
Exemplo n.º 29
0
        public Dictionary <string, string[]> Validate(Context db, Draft draft,
                                                      ValidationLevel level = ValidationLevel.Warning)
        {
            ValidationLevel[] levels;
            switch (level)
            {
            case ValidationLevel.Error:
                levels = new[] { ValidationLevel.Error };
                break;

            case ValidationLevel.Warning:
            default:
                levels = new[] { ValidationLevel.Warning, ValidationLevel.Error };
                break;
            }

            var ValidationErrors = new Dictionary <string, string[]>();

            var fields = AllFields(db);

            foreach (var field in fields)
            {
                var validations = field.Validations;
                if (validations == null)
                {
                    validations = new List <Validation>()
                    {
                    }
                }
                ;
                foreach (var validation in validations)
                {
                    if (!levels.Contains(validation.Level))
                    {
                        continue;
                    }
                    var key    = field.StoredColumn;
                    var errors = new List <string>();
                    if (validation.IsNotValid(draft, db))
                    {
                        errors.Add(validation.ReadableMessage(field));
                    }
                    if (errors.Count > 0)
                    {
                        ValidationErrors.Add(key, errors.ToArray());
                    }
                }
            }

            return(ValidationErrors);
        }
 /// <summary>
 /// コンストラクタ。
 /// </summary>
 /// <param name="name">ルール名</param>
 /// <param name="references">コンポーネントリスト</param>
 /// <param name="ignorePrefabGUIDs">例外Prefabのリスト</param>
 /// <param name="unregisteredComponent">リストにないコンポーネントの扱い</param>
 public UsableComponentListRule(string name,
                                ComponentReference[] references,
                                string[] ignorePrefabGUIDs            = null,
                                ValidationLevel unregisteredComponent = ValidationLevel.ALLOW)
     : base(name)
 {
     this.references = references ?? new ComponentReference[] { };
     if (ignorePrefabGUIDs == null)
     {
         ignorePrefabGUIDs = new string[0];
     }
     ignorePrefabs = new HashSet <string>(ignorePrefabGUIDs);
     unregisteredComponentValidationLevel = unregisteredComponent;
 }
Exemplo n.º 31
0
 /// <summary>
 /// コンストラクタ。
 /// </summary>
 /// <param name="name">ルール名</param>
 /// <param name="references">アセンブリリスト</param>
 /// <param name="ignorePrefabGUIDs">例外Prefabのリスト</param>
 /// <param name="unregisteredAssembly">リストにないアセンブリの扱い</param>
 public UsableUdonAssemblyListRule(string name,
                                   UdonAssemblyReference[] references,
                                   string[] ignorePrefabGUIDs           = null,
                                   ValidationLevel unregisteredAssembly = ValidationLevel.ALLOW)
     : base(name)
 {
     this._references = references ?? new UdonAssemblyReference[] { };
     if (ignorePrefabGUIDs == null)
     {
         ignorePrefabGUIDs = new string[0];
     }
     _ignorePrefabs = new HashSet <string>(ignorePrefabGUIDs);
     _unregisteredAssemblyValidationLevel = unregisteredAssembly;
 }
        /// <summary>
        /// Bakes a combined mesh.
        /// </summary>
        /// <param name="mom"></param>
        /// <param name="so">This is needed to work around a Unity bug where UnpackPrefabInstance corrupts
        /// a SerializedObject. Only needed for bake into prefab.</param>
        public static bool bake(MeshBakerCommon mom, ref SerializedObject so)
        {
            bool createdDummyTextureBakeResults = false;
            bool success = false;

            try
            {
                if (mom.meshCombiner.outputOption == OutputOptions.bakeIntoSceneObject ||
                    mom.meshCombiner.outputOption == OutputOptions.bakeIntoPrefab)
                {
                    success = MeshCombinerEditorFunctions.BakeIntoCombined(mom, out createdDummyTextureBakeResults, ref so);
                }
                else
                {
                    //bake meshes in place
                    if (mom is MeshCombinerEntrance)
                    {
                        ValidationLevel vl = Application.isPlaying ? ValidationLevel.quick : ValidationLevel.robust;
                        if (!MeshBakerRoot.DoCombinedValidate(mom, ObjsToCombineTypes.prefabOnly, new EditorMethods(), vl))
                        {
                            return(false);
                        }

                        List <GameObject> objsToMesh = mom.GetObjectsToCombine();
                        ////success = MB3_BakeInPlace.BakeMeshesInPlace((MeshCombineHandler)((MeshCombinerEntrance)mom).meshCombiner, objsToMesh, mom.bakeAssetsInPlaceFolderPath, mom.clearBuffersAfterBake, updateProgressBar);
                    }
                    else
                    {
                        //多网格合并无法 Bake In Place
                        Debug.LogError("Multi-mesh Baker components cannot be used for Bake In Place. Use an ordinary Mesh Baker object instead.");
                    }
                }
                mom.meshCombiner.CheckIntegrity();
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
            finally
            {
                if (createdDummyTextureBakeResults && mom.textureBakeResults != null)
                {
                    MeshBakerUtility.Destroy(mom.textureBakeResults);
                    mom.textureBakeResults = null;
                }
                EditorUtility.ClearProgressBar();
            }
            return(success);
        }
Exemplo n.º 33
0
        /// <summary>
        /// Performs checks on the event store
        /// </summary>
        /// <param name="validationLevel">Validation level</param>
        /// <param name="registry">Event store</param>
        internal static void Validate(ValidationLevel validationLevel, Dictionary <Type, TerminateEventArgs> registry)
        {
            if (validationLevel.HasFlag(ValidationLevel.ExitCodeOnlyOnce))
            {
                var multipleUsage = (from r in registry
                                     group r by r.Value.ExitCode
                                     into m
                                     where m.Count() > 1
                                     select m);

                if (multipleUsage.Any())
                {
                    var code = multipleUsage.First();

                    throw new ArgumentException($"Code {code.Key} is used more than once.");
                }
            }
        }
Exemplo n.º 34
0
        /// <summary>
        /// Logs an entry.
        /// </summary>
        /// <param name="level">The validation level (error, warning or information).</param>
        /// <param name="description">The entry description.</param>
        /// <param name="type">The type of entry.</param>
        /// <param name="code">A code representing the entry.</param>
        /// <param name="severity">The severity of the entry (error only).</param>
        private void LogEntry(ValidationLevel level, string description, string type = null, long?code = null, int?severity = null)
        {
            var validationEntry = new ValidationEntry(level, description, type, code, severity);

            switch (level)
            {
            case ValidationLevel.Error:
                this.errors.Add(validationEntry);
                break;

            case ValidationLevel.Warning:
                this.warnings.Add(validationEntry);
                break;

            case ValidationLevel.Information:
                this.information.Add(validationEntry);
                break;
            }
        }
Exemplo n.º 35
0
        /// <summary>
        /// Returns a string representing all entries of a given level.
        /// </summary>
        /// <param name="level">
        /// The validation level.
        /// </param>
        /// <returns>
        /// The <see cref="string"/> representing all error entries.
        /// </returns>
        public string ToString(ValidationLevel level)
        {
            IEnumerable <ValidationEntry> list = this.errors;

            switch (level)
            {
            case ValidationLevel.Error:
                if (this.ErrorCount <= 0)
                {
                    return(string.Empty);
                }

                break;

            case ValidationLevel.Warning:
                if (this.WarningCount <= 0)
                {
                    return(string.Empty);
                }

                list = this.Warnings;
                break;

            case ValidationLevel.Information:
                if (this.InformationCount <= 0)
                {
                    return(string.Empty);
                }

                list = this.Information;
                break;
            }

            var errorsStringBuilder = new StringBuilder();

            foreach (var validationEntry in list)
            {
                errorsStringBuilder.Append(validationEntry);
            }

            return(errorsStringBuilder.ToString());
        }
Exemplo n.º 36
0
        /// <summary>
        /// Füllt das TreeControl rekursiv
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private TreeNode createRootNode(ConfigFile file)
        {
            string   filename = file.Path.Substring(file.Path.LastIndexOf('\\') + 1); //TODO filename prop
            TreeNode node     = new TreeNode(filename);

            node.Tag = file.Path;

            ValidationLevel state = file.getValidationLevel();

            switch (state)
            {
            case ValidationLevel.Unknown:
                node.BackColor = Color.LightGray;
                break;

            case ValidationLevel.Ok:
                break;

            case ValidationLevel.Error:
                node.BackColor = Color.Red;
                break;

            case ValidationLevel.Warning:
                node.BackColor = Color.Orange;
                break;

            default:
                break;
            }

            foreach (WeakReference cfgFileRef in file.SubConfigRef)
            {
                node.Nodes.Add(createRootNode((ConfigFile)cfgFileRef.Target));
            }

            return(node);
        }
Exemplo n.º 37
0
        /// <summary>
        /// Performs checks on an individual termination event
        /// </summary>
        /// <param name="validationLevel">Validation level</param>
        /// <param name="terminateEventArgs">Termination event</param>
        internal static void Validate(ValidationLevel validationLevel, TerminateEventArgs terminateEventArgs)
        {
            if (validationLevel.HasFlag(ValidationLevel.ExitCodeWithBoundaries))
            {
                if (terminateEventArgs.ExitCode > TerminatorBuilder.MaxErrorExitCode)
                {
                    throw new ArgumentOutOfRangeException($"{nameof(terminateEventArgs.ExitCode)} cannot be greater than {nameof(TerminatorBuilder.MaxErrorExitCode)}: {TerminatorBuilder.MaxErrorExitCode}");
                }
                else if (terminateEventArgs.ExitCode < 0)
                {
                    throw new ArgumentOutOfRangeException($"{nameof(terminateEventArgs.ExitCode)} cannot be less than 0.");
                }
            }

            if (validationLevel.HasFlag(ValidationLevel.ExitCodeNotInReservedSpace))
            {
                if (Enum.IsDefined(typeof(UnixCode), terminateEventArgs.ExitCode))
                {
                    var linuxExitCode = (UnixCode)terminateEventArgs.ExitCode;

                    throw new ArgumentException($"Exit code {terminateEventArgs.ExitCode} is already defined by {nameof(UnixCode)}: {linuxExitCode}");
                }
            }
        }
Exemplo n.º 38
0
        public override ValidationLevel validate()
        {
            ValidationLevel validationResult = ValidationLevel.Ok;

            ValidationMessage = "";

            //Warnungen:
            //File existiert nicht
            if (!System.IO.File.Exists(cfgDirPath + this.filename))
            {
                ValidationMessage = String.Format("Die Referenzierte Datei {0} existiert nicht!", this.filename);
                validationResult  = ValidationLevel.Warning;
            }

            //Errors:
            //Loop wurde erkannt
            if (this.loopDetected)
            {
                ValidationMessage = String.Format("Die Referenz zur Datei {0} erzeugt eine Endlosschleife!", this.filename);
                validationResult  = ValidationLevel.Error;
            }
            this.validationState = validationResult;
            return(validationResult);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncGroupValidationAttribute"/> class.
 /// </summary>
 /// <param name="validationLevel">The validation level (Error, Warning).</param>
 protected AsyncGroupValidationAttribute(ValidationLevel validationLevel = ValidationLevel.Error)
     : base(validationLevel)
 {
 }
Exemplo n.º 40
0
		/// <summary>Validates collection SalesOrderHeaderChildren2.</summary>
		protected BusinessRuleCollection ValidateSalesOrderHeaderChildren2(ValidationLevel level)
		{
            BusinessRuleCollection rules = new BusinessRuleCollection();
            SalesOrderHeader.ConvertEntitiesToBusinessObjects(this.SalesOrderHeaderChildren2);
            foreach (IBusinessObject bizobj in this.SalesOrderHeaderChildren2)
                rules.Add(bizobj.Validate(level));

            return rules.GetBrokenRules();
		}
Exemplo n.º 41
0
		/// <summary>Validates collection CustomerAddressChildren.</summary>
		protected BusinessRuleCollection ValidateCustomerAddressChildren(ValidationLevel level)
		{
            BusinessRuleCollection rules = new BusinessRuleCollection();
            CustomerAddress.ConvertEntitiesToBusinessObjects(this.CustomerAddressChildren);
            foreach (IBusinessObject bizobj in this.CustomerAddressChildren)
                rules.Add(bizobj.Validate(level));

            return rules.GetBrokenRules();
		}
Exemplo n.º 42
0
		protected virtual void ValidateChildren(BusinessRuleCollection rules, ValidationLevel level)
		{
			rules.Add(ValidateCustomerAddressChildren(level));
			rules.Add(ValidateSalesOrderHeaderChildren(level));
			rules.Add(ValidateSalesOrderHeaderChildren2(level));
		}
Exemplo n.º 43
0
		protected virtual void ValidateChildren(BusinessRuleCollection rules, ValidationLevel level)
		{
			rules.Add(ValidateProductChildren(level));
			rules.Add(ValidateProductCategoryChildren(level));
		}
Exemplo n.º 44
0
		protected virtual void ValidateChildren(BusinessRuleCollection rules, ValidationLevel level)
		{
		}
        /// <summary>
        /// Manually adds a validation message for a given property with a certain level.
        /// </summary>
        /// <param name="propertySelector">Selector of the validated property.</param>
        /// <param name="validationLevel">Level of the validation message.</param>
        /// <param name="messageText">Validation message text.</param>
        /// <param name="showMessageOnProperty">Indicates if the message should be shown on the property at the UI.</param>
        /// <param name="showMessageInSummary">Indicates if the message should be shown in the validation summary at the UI.</param>
        /// <returns><c>true</c>, if the message has been added. <c>false</c>, if it was already there.</returns>
        public bool AddMessage(
            Expression<Func<object>> propertySelector,
            ValidationLevel validationLevel,
            string messageText,
            bool showMessageOnProperty = true,
            bool showMessageInSummary = true)
        {
            Guard.AssertNotNull(propertySelector, "propertySelector");

            string propertyName = propertySelector.ExtractPropertyName();
            var validationMessage = new ValidationMessage(validationLevel, messageText, showMessageOnProperty, showMessageInSummary, ValidationMessageKind.Property);

            return this.AddMessage(propertyName, validationMessage);
        }
Exemplo n.º 46
0
		/// <summary>Saves biz object if actor has required permission and if biz object is valid.</summary>
		public virtual BusinessRuleCollection SaveIfValid(IActor actor, ValidationLevel level, bool enforceSecurityChecks)
		{
				// Validate object.
				BusinessRuleCollection rules = new BusinessRuleCollection();
				rules.Add(Validate(level));
				if (rules.HasBrokenRules)
				    return rules.GetBrokenRules();

				// Check permissions.
				if (enforceSecurityChecks && !this.IsNew)
				    rules.Add(GrantSave(actor));

				if (enforceSecurityChecks && this.IsNew)
				    rules.Add(GrantCreate(actor));

				if (rules.HasBrokenRules)
				    return rules.GetBrokenRules();

				// Save if valid and actor has all required permissions.
				Save(actor);
				return rules.GetBrokenRules();
		}
 /// <summary>
 /// 
 /// </summary>
 /// <param name="criterionName"></param>
 /// <param name="level"></param>
 /// <param name="maxLength"></param>
 /// <param name="caseSensitive"></param>
 /// <param name="trim"></param>
 /// <param name="customMessages"></param>
 public MaxLengthFieldCriterion(string criterionName, ValidationLevel level, int maxLength,
                                bool caseSensitive, bool trim, CustomValidationMessages customMessages)
     : base(criterionName, level, null, caseSensitive, trim, customMessages)
 {
     this.MaxLength = maxLength;
 }
Exemplo n.º 48
0
		protected virtual void ValidateChildren(BusinessRuleCollection rules, ValidationLevel level)
		{
			rules.Add(ValidateProductModelProductDescriptionChildren(level));
		}
Exemplo n.º 49
0
 public Commando(CommandType type)
 {
     this.commandType = type;
     this.validationState = ValidationLevel.Unknown;
 }
Exemplo n.º 50
0
		/// <summary>Validates collection ProductCategoryChildren.</summary>
		protected BusinessRuleCollection ValidateProductCategoryChildren(ValidationLevel level)
		{
            BusinessRuleCollection rules = new BusinessRuleCollection();
            ProductCategory.ConvertEntitiesToBusinessObjects(this.ProductCategoryChildren);
            foreach (IBusinessObject bizobj in this.ProductCategoryChildren)
                rules.Add(bizobj.Validate(level));

            return rules.GetBrokenRules();
		}
Exemplo n.º 51
0
		/// <summary>Validates objec.</summary>
		public virtual BusinessRuleCollection Validate(ValidationLevel level)
		{
				BusinessRuleCollection rules = new BusinessRuleCollection();
				rules.Add(DALHelper.CheckEntityRules(this));
				if (rules.AllRulesAreObeyed && level > ValidationLevel.BasicFieldConstraints)
				    ValidateChildren(rules, level);

				return rules.GetBrokenRules();
		}
Exemplo n.º 52
0
		protected virtual void ValidateChildren(BusinessRuleCollection rules, ValidationLevel level)
		{
			rules.Add(ValidateSalesOrderDetailChildren(level));
		}
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="criterionName"></param>
 /// <param name="dataType"></param>
 /// <param name="level"></param>
 /// <param name="caseSensitive"></param>
 /// <param name="trim"></param>
 /// <param name="customMessages"></param>
 public RequiredFieldCriterion(string criterionName, ValidationLevel level, Type dataType, bool caseSensitive,
                               bool trim, CustomValidationMessages customMessages)
     : base(criterionName, level, caseSensitive, trim, customMessages)
 {
     this.m_dataType = dataType;
 }
Exemplo n.º 54
0
 public List<Xiap.Framework.DataMapping.Payload> ProcessData(List<Xiap.Framework.DataMapping.Payload> requestedChanges, Xiap.Framework.DataMapping.VirtualProcessRequest virtualProcessRequest, ValidationLevel validationLevel, bool forceFullDataRetrieval, Action action, bool resumeTransaction, bool treatWarningsAsErrors = false)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Manually adds a validation message of a certain level to the entire entity.
 /// </summary>
 /// <param name="validationLevel">Level of the validation message (Error, Warning).</param>
 /// <param name="messageText">Validation message text.</param>
 /// <returns><c>true</c>, if the message has been added. <c>false</c>, if it was already there.</returns>
 public bool AddMessage(ValidationLevel validationLevel, string messageText)
 {
     return this.AddMessage(new ValidationMessage(validationLevel, messageText, ValidationMessageKind.Overall));
 }
Exemplo n.º 56
0
 public List<Xiap.Framework.DataMapping.Payload> ProcessData(List<Xiap.Framework.DataMapping.Payload> requestedChanges, Xiap.Framework.DataMapping.VirtualProcessRequest virtualProcessRequest, ValidationLevel validationLevel, bool forceFullDataRetrieval)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="criterionName"></param>
 /// <param name="level"></param>
 /// <param name="maxLength"></param>
 /// <param name="caseSensitive"></param>
 /// <param name="trim"></param>
 /// <param name="customMessages"></param>
 public MaxLengthFieldCriterion(string criterionName, ValidationLevel level, int maxLength,
                                bool caseSensitive, bool trim, CustomValidationMessages customMessages)
     : base(criterionName, level, null, caseSensitive, trim, customMessages)
 {
     this.MaxLength = maxLength;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncValidationAttribute"/> class by using the error message to associate with a validation control.
 /// </summary>
 /// <param name="errorMessage">
 /// The error message to associate with a validation control.
 /// </param>
 /// <param name="validationLevel">
 /// The validation level (Error, Warning).
 /// </param>
 /// <param name="useInImplicitValidation">
 /// Indicates if the validation of this attribute will be triggered by a property change.
 /// </param>
 /// <param name="showMessageOnProperty">
 /// Indicates whether the validation message will be shown on the property at the UI.
 /// </param>
 /// <param name="showMessageInSummary">
 /// Indicates whether the validation message will be shown in the validation summary at the UI.
 /// </param>
 protected AsyncValidationAttribute(
     string errorMessage,
     ValidationLevel validationLevel = ValidationLevel.Error,
     bool useInImplicitValidation = true,
     bool showMessageOnProperty = true,
     bool showMessageInSummary = true)
     : this(validationLevel, useInImplicitValidation, showMessageOnProperty, showMessageInSummary)
 {
     this.ErrorMessage = errorMessage;
 }