public virtual IDockingElement ResolvePath(string path)
{
// Cannot resolve a null reference
if (path == null)
throw new ArgumentNullException("path");
// Path names cannot be zero length
if (path.Length == 0)
throw new ArgumentException("path");
// Extract the first name in the path
int comma = path.IndexOf(',');
string firstName = (comma == -1 ? path : path.Substring(0, comma));
// If the first name matches ourself...
if (firstName == Name)
{
// If there are no other names then we are the target
if (firstName.Length == path.Length)
return this;
else
{
// Extract the remainder of the path
string remainder = path.Substring(comma, path.Length - comma);
// Give each child a chance to resolve the remainder of the path
foreach (IDockingElement child in this)
{
IDockingElement ret = child.ResolvePath(remainder);
if (ret != null)
return ret;
}
}
}
return null;
}