/// <summary> /// Find the longest matching path which we know about and return that <see cref="IActorRef"/> /// (or ask that <see cref="IActorRef"/> to continue searching if elements are left). /// </summary> /// <param name="name">The name.</param> /// <returns>ActorRef.</returns> public override IActorRef GetChild(IEnumerable <string> name) { var path = name.Join("/"); var n = 0; while (true) { var nameAndUid = ActorCell.SplitNameAndUid(path); if (TryGetChild(nameAndUid.Name, out var child)) { if (nameAndUid.Uid != ActorCell.UndefinedUid && nameAndUid.Uid != child.Path.Uid) { return(Nobody.Instance); } return(n == 0 ? child : child.GetChild(name.TakeRight(n))); } var last = path.LastIndexOf("/", StringComparison.Ordinal); if (last == -1) { return(Nobody.Instance); } path = path.Substring(0, last); n++; } }
/// <summary> /// Find the longest matching path which we know about and return that <see cref="IActorRef"/> /// (or ask that <see cref="IActorRef"/> to continue searching if elements are left). /// </summary> /// <param name="name">The name.</param> /// <returns>ActorRef.</returns> public override IActorRef GetChild(IEnumerable <string> name) { var elements = name.ToArray(); var path = elements.Join("/"); var n = 0; while (true) { var nameAndUid = ActorCell.SplitNameAndUid(path); var child = GetChild(nameAndUid.Name); if (child == null) { var last = path.LastIndexOf("/", StringComparison.Ordinal); if (last == -1) { return(Nobody.Instance); } path = path.Substring(0, last); n++; continue; } if (nameAndUid.Uid != ActorCell.UndefinedUid && nameAndUid.Uid != child.Path.Uid) { return(Nobody.Instance); } return(n == 0 ? child : child.GetChild(elements.TakeRight(n))); } }
private IInternalActorRef GetChild(string name) { var nameAndUid = ActorCell.SplitNameAndUid(name); IInternalActorRef child; if (TryGetChild(nameAndUid.Name, out child)) { if (nameAndUid.Uid != ActorCell.UndefinedUid && nameAndUid.Uid != child.Path.Uid) { return(ActorRefs.Nobody); } } return(child); }
public NameAndUid ActorCell_SplitNameAndUid() { return(ActorCell.SplitNameAndUid(ActorPath)); }