public StyleSheet Refresh()
 {
     Rules.Clear();
     m_ResolvedSheet = null;
     Variables.Clear();
     ParentToChildren.Clear();
     ChildToParent.Clear();
     return(ResolvedSheet);
 }
        private Rule GetParentRule(string childSelectorName)
        {
            Rule parentRule = null;

            if (ChildToParent.ContainsKey(childSelectorName))
            {
                Rules.TryGetValue(ChildToParent[childSelectorName], out parentRule);
            }
            return(parentRule);
        }
        private void ResolveRules(StyleSheet sheet)
        {
            foreach (var complexSelector in sheet.complexSelectors)
            {
                if (complexSelector.rule == null)
                {
                    continue;
                }

                var  selectorName = StyleSheetToUss.ToUssSelector(complexSelector);
                Rule aggregateRule;
                if (!Rules.TryGetValue(selectorName, out aggregateRule))
                {
                    aggregateRule = new Rule(selectorName, complexSelector, complexSelector.rule.line);
                    Rules.Add(selectorName, aggregateRule);
                }

                // Override existing properties and append new ones:
                foreach (var property in complexSelector.rule.properties)
                {
                    Property dstProp;
                    if (aggregateRule.Properties.TryGetValue(property.name, out dstProp))
                    {
                        dstProp.Values = ToValues(property, sheet);
                    }
                    else
                    {
                        dstProp = AddProperty(aggregateRule, property, sheet);
                    }
                    if (dstProp.Name.StartsWith("--"))
                    {
                        Variables.Set(dstProp.Name, dstProp);
                    }
                }

                Property derivationProperty;
                if (aggregateRule.Properties.TryGetValue(ConverterUtils.k_Extend, out derivationProperty))
                {
                    var        parentName = derivationProperty.Values[0].AsString();
                    ExtendData derivationData;
                    if (!ParentToChildren.TryGetValue(parentName, out derivationData))
                    {
                        derivationData = new ExtendData(parentName);
                        ParentToChildren.Add(parentName, derivationData);
                    }
                    derivationData.ChildrenRules.Add(aggregateRule);
                    if (!ChildToParent.ContainsKey(aggregateRule.SelectorName))
                    {
                        ChildToParent.Add(aggregateRule.SelectorName, parentName);
                    }
                }
            }
        }