mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 15:37:51 -08:00
Fix adding parts
This commit is contained in:
@@ -10,7 +10,12 @@ internal abstract class ParentPart : Part
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool TryAdd(IPart part, out Message message)
|
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);
|
protected abstract bool TryAddCore(IPart part, out Message message);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user