public static IEnumerable <ILogical> GetSelfAndLogicalAncestors(this ILogical logical) { yield return(logical); foreach (var ancestor in logical.GetLogicalAncestors()) { yield return(ancestor); } }
public static IObservable <ILogical> Track(ILogical relativeTo, int ancestorLevel, Type ancestorType = null) { return(TrackAttachmentToTree(relativeTo).Select(isAttachedToTree => { if (isAttachedToTree) { return relativeTo.GetLogicalAncestors() .Where(x => ancestorType?.GetTypeInfo().IsAssignableFrom(x.GetType().GetTypeInfo()) ?? true) .ElementAtOrDefault(ancestorLevel); } else { return null; } })); }
private void Update() { _value = _relativeTo.GetLogicalAncestors() .Where(x => _ancestorType?.IsAssignableFrom(x.GetType()) ?? true) .ElementAtOrDefault(_ancestorLevel); }
public static bool IsLogicalParentOf(this ILogical logical, ILogical target) { return(target.GetLogicalAncestors().Any(x => x == logical)); }