using System; [Serializable] public abstract class KeyCompare { public abstract bool Match(object obj); } [Serializable] public class DefaultKey : KeyCompare { public override bool Match(object obj) => true; } [Serializable] public class MatePropertyKey : KeyCompare { public MateProperty target; public override bool Match(object obj) => obj is MateProperty mate && mate.id == target.id; }