///<summary> /// Returns true if the component matches the selector ///</summary> ///<param name="component"></param> ///<param name="selector"></param> ///<returns></returns> internal bool MatchesSelector(Component component, Selector selector) { if (null == component) { throw new Exception("Component is null"); } if (null == selector) { throw new Exception("Selector is null"); } var type = component.GetType(); /** * 1. Check subject * */ if (type.FullName != selector.Subject) { return(false); } if (0 == selector.Conditions.Count) { return(true); // nothing more to do } /** * 1. Default adapter * */ _styleClient = _defaultAdapter; /** * 2. If specified for a component... * */ if (_adapters.ContainsKey(type)) { _styleClient = _adapters[type]; } /** * 3. Initialize with component instance * */ _styleClient.Initialize(component); /** * 4. Check conditions * */ foreach (CSSCondition condition in selector.Conditions) { if (!condition.MatchesStyleClient(_styleClient)) { return(false); } } return(true); }
///<summary> /// Returns true if the component matches the selector ///</summary> ///<param name="component"></param> ///<param name="selector"></param> ///<returns></returns> internal bool MatchesSelector(Component component, Selector selector) { if (null == component) throw new Exception("Component is null"); if (null == selector) throw new Exception("Selector is null"); var type = component.GetType(); /** * 1. Check subject * */ if (type.FullName != selector.Subject) return false; if (0 == selector.Conditions.Count) return true; // nothing more to do /** * 1. Default adapter * */ _styleClient = _defaultAdapter; /** * 2. If specified for a component... * */ if (_adapters.ContainsKey(type)) _styleClient = _adapters[type]; /** * 3. Initialize with component instance * */ _styleClient.Initialize(component); /** * 4. Check conditions * */ foreach (CSSCondition condition in selector.Conditions) { if (!condition.MatchesStyleClient(_styleClient)) return false; } return true; }