using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; namespace DCIT.Core.Models { public class RuleDefinition : INotifyPropertyChanged { private string _id; private string _name; private bool _isEnabled = true; private RuleMatchMode _matchMode = RuleMatchMode.PlainText; private bool _isCaseSensitive; private bool _isWholeWord; private RuleTarget _target = RuleTarget.DocumentContent; private string _searchText; private string _replacementText; private string _note; public string Id { get { return _id; } set { SetField(ref _id, value); } } public string Name { get { return _name; } set { SetField(ref _name, value); } } public bool IsEnabled { get { return _isEnabled; } set { SetField(ref _isEnabled, value); } } public RuleMatchMode MatchMode { get { return _matchMode; } set { SetField(ref _matchMode, value); } } public RuleTarget Target { get { return _target; } set { SetField(ref _target, value); } } public bool IsCaseSensitive { get { return _isCaseSensitive; } set { SetField(ref _isCaseSensitive, value); } } public bool IsWholeWord { get { return _isWholeWord; } set { SetField(ref _isWholeWord, value); } } public string SearchText { get { return _searchText; } set { SetField(ref _searchText, value); } } public string ReplacementText { get { return _replacementText; } set { SetField(ref _replacementText, value); } } public string Note { get { return _note; } set { SetField(ref _note, value); } } public event PropertyChangedEventHandler PropertyChanged; protected void SetField(ref T field, T value, [CallerMemberName] string propertyName = null) { if (EqualityComparer.Default.Equals(field, value)) { return; } field = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } public class RuleFile { public string Format { get; set; } = "dcit.rule"; public string Version { get; set; } = "1.0"; public List Rules { get; set; } = new List(); } public class RuleValidationIssue { public RuleValidationSeverity Severity { get; set; } public int Index { get; set; } public string RuleId { get; set; } public string RuleName { get; set; } public string Message { get; set; } } public class RuleValidationReport { public List Issues { get; } = new List(); public bool HasErrors { get { return Issues.Exists(item => item.Severity == RuleValidationSeverity.Error); } } } }