mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-03-21 17:48:28 -05:00
With the new version of Visual Studio bringing C# 12, we can revise our logic for better readability as well as use new methods/APIs introduced in the .NET 8.0 BCL.
17 lines
668 B
C#
17 lines
668 B
C#
using System;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <inheritdoc cref="IComplexSet"/>
|
|
public sealed class ComplexSet(string PropertyName, Action<PKM, StringInstruction> Action) : IComplexSet
|
|
{
|
|
public readonly string PropertyName = PropertyName;
|
|
public readonly Func<string, bool> IsValueCompatible = _ => true;
|
|
|
|
public ComplexSet(string PropertyName, Func<string, bool> criteria, Action<PKM, StringInstruction> Action) : this(PropertyName, Action) => IsValueCompatible = criteria;
|
|
|
|
public bool IsMatch(string name, string value) => name == PropertyName && IsValueCompatible(value);
|
|
|
|
public void Modify(PKM pk, StringInstruction instr) => Action(pk, instr);
|
|
}
|