using Newtonsoft.Json;
using RuriLib.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RuriLib.Models
{
///
/// The condition for which a Rule is tested.
///
public enum RuleType
{
/// The slice must contain the given characters.
MustContain,
/// The slice must not contain the given characters.
MustNotContain,
/// The slice's length must be greater or equal to a given number.
MinLength,
/// The slice's length must be smaller or equal to a given number.
MaxLength,
/// The slice must match a given regex pattern.
MustMatchRegex
}
///
/// Represents a rule that the data line must respect in order to be valid for a given Config.
///
public class DataRule : ViewModelBase
{
private string sliceName = "";
/// The name of the specific slice (defined in the WordlistType) this rule refers to.
public string SliceName { get { return sliceName; } set { sliceName = value; OnPropertyChanged(); } }
private RuleType ruleType = RuleType.MustContain;
/// The type of the rule.
public RuleType RuleType { get { return ruleType; } set { ruleType = value; OnPropertyChanged(); } }
private string ruleString = "Lowercase";
/// The characters to search in the sliced value. Defaults are Lowercase, Uppercase, Digit, Symbol. Custom character sets can be created by concatenating the characters in a single string (e.g. ABCDEF).
public string RuleString { get { return ruleString; } set { ruleString = value; OnPropertyChanged(); } }
/// The id of the rule.
public int Id { get; set; }
/// Whether the type has been initialized. Used in the View.
[JsonIgnore]
public bool TypeInitialized { get; set; } = false;
/// Whether the right-hand term has been initialized. Used in the View.
[JsonIgnore]
public bool StringInitialized { get; set; } = false;
///
/// Creates a DataRule given an id.
///
/// The unique id of the rule
public DataRule(int id)
{
Id = id;
}
}
}