public static bool TryGetByName <T>(this IHasChildren <T> @this, string name, out T child) { bool success; child = @this.TryGetByName(name, out success); return(success); }
private bool TryGetByNameInner <T>(IHasChildren <object> currentParent, string subname, out T result) where T : class { if (subname == null) { result = null; return(false); } var parts = subname.Split(new [] { Machine.PathSeparator }, 2); object candidate; if (!currentParent.TryGetByName(parts[0], out candidate)) { result = null; return(false); } result = candidate as T; if (parts.Length == 1) { return(result != null); } var parent = candidate as IHasChildren <object>; if (parent != null) { return(TryGetByNameInner(parent, parts[1], out result)); } return(false); }