mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-25 03:43:16 +00:00
6ee552b860
seal the classes, no need to derive (nothing virtual)
24 lines
875 B
C#
24 lines
875 B
C#
using System;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
/// <inheritdoc cref="IComplexSet"/>
|
|
public sealed class ComplexSet : IComplexSet
|
|
{
|
|
public readonly string PropertyName;
|
|
public readonly Func<string, bool> IsValueCompatible = _ => true;
|
|
private readonly Action<PKM, StringInstruction> Action;
|
|
|
|
public ComplexSet(string propertyName, Action<PKM, StringInstruction> modify)
|
|
{
|
|
PropertyName = propertyName;
|
|
Action = modify;
|
|
}
|
|
|
|
public ComplexSet(string propertyName, Func<string, bool> criteria, Action<PKM, StringInstruction> modify) : this(propertyName, modify) => IsValueCompatible = criteria;
|
|
|
|
public bool IsMatch(string name, string value) => name == PropertyName && IsValueCompatible(value);
|
|
|
|
public void Modify(PKM pk, StringInstruction instr) => Action(pk, instr);
|
|
}
|
|
}
|