/// <summary> /// Create a child Navigator of the given parent. /// </summary> public Navigator(Navigator parent) { ValidateParentIsNonTerminating(parent); destinationParts = parent.DestinationParts; destinationPartIndex = parent.DestinationPartIndex + 1; context = parent.Context.GetImmediateSimulatableRelative(destinationParts[destinationPartIndex]); }
/// <summary> /// Get the simulatable relative, immediate or distant, using the given navigator. /// May return null if the relative is not found. /// </summary> public Simulatable GetSimulatableRelative(Navigator navigator) { return navigator.IsTerminating ? navigator.Context : navigator.Context.GetSimulatableRelative(new Navigator(navigator)); }
private static void ValidateParentIsNonTerminating(Navigator parent) { if (parent.IsTerminating) throw new ArgumentException("Cannot make a child from a terminating navigator."); }