Fix adding parts

This commit is contained in:
Andrew Cooper
2022-07-13 08:15:46 +10:00
parent 013baf71a2
commit a648ebf044

View File

@@ -10,7 +10,12 @@ internal abstract class ParentPart : Part
}
public bool TryAdd(IPart part, out Message message)
=> IsPresent ? TryAddCore(part, out message) : ReportDoNotHave(out message);
=> (part.GetType() == GetType(), IsPresent) switch
{
(true, _) => TryAdd(out message),
(false, false) => ReportDoNotHave(out message),
_ => TryAddCore(part, out message)
};
protected abstract bool TryAddCore(IPart part, out Message message);