public static T GetChild <T>(IOwner owner, string key, bool isDebug = false) where T : class, IElement { if (owner == null) { return(null); } T child = null; IDict ownerAsDict = owner as IDict; if (ownerAsDict != null) { child = ownerAsDict.Get <IInDictElement>(key, isDebug) as T; } else { ITable ownerAsTable = owner as ITable; if (ownerAsTable != null) { child = ownerAsTable.GetByKey <IInTableElement>(key, isDebug) as T; } } if (child == null) { owner.ErrorOrDebug(isDebug, "Not Found: {0}", key); } return(child); }
public static T GetDescendant <T>(IOwner owner, string[] keys, int startIndex, bool isDebug = false) where T : class, IElement { IObject current = owner; for (int i = startIndex; i < keys.Length; i++) { current = GetChild <IElement>(current as IOwner, keys[i], isDebug); if (current == null) { return(null); } } T result = current as T; if (result == null) { owner.ErrorOrDebug(isDebug, "Type Mismatched: <{0}> {1} {2} -> {3}", typeof(T).FullName, string.Join(PathConsts.PathSeparatorAsString, keys), startIndex, current); } return(result); }