/// <summary> /// looks for the "As face" by walking ALL the decorations. If DecoratorAware, walks down from Outer. If not /// DecoratorAware, walks down from Self /// </summary> /// <param name="obj"></param> /// <param name="decorationType"></param> /// <param name="exactTypeMatch"></param> /// <returns></returns> public static object As(this object obj, Type decorationType, bool exactTypeMatch) { if (obj == null) { return(null); } //if decorator aware get the outer object topMost = obj; if (IDecoratorAwareDecorationExtensions.IsADecoratorAwareDecoration(obj)) { topMost = IDecoratorAwareDecorationExtensions.GetOuterDecorator(obj); } return(AsBelow(topMost, decorationType, exactTypeMatch)); }
/// <summary> /// If DecoratorAware, walks down from Outer. If not DecoratorAware, walks down from Self /// </summary> public static List <object> GetAllDecorations(this object obj) { List <object> rv = new List <object>(); if (obj == null) { return(rv); } //if decorator aware get the outer object topMost = obj; if (IDecoratorAwareDecorationExtensions.IsADecoratorAwareDecoration(obj)) { topMost = IDecoratorAwareDecorationExtensions.GetOuterDecorator(obj); } rv = IDecorationExtensions.GetSelfAndAllDecorationsBelow(topMost); return(rv); }