public CSSFragmentBuilderSelector AddChild(ICSSFragmentBuilderComponent child) { if (child == null) { throw new ArgumentNullException("child"); } return(AddChildren(new[] { child })); }
private static IEnumerable <ICSSFragment> Translate(ICSSFragmentBuilderComponent source, IEnumerable <ContainerFragment.SelectorSet> parentSelectors) { if (source == null) { throw new ArgumentNullException("source"); } if (parentSelectors == null) { throw new ArgumentNullException("parentSelectors"); } var parentSelectorsArray = parentSelectors.ToArray(); if (parentSelectorsArray.Any(s => s == null)) { throw new ArgumentException("Null reference encountered in parentSelectors set"); } var styleProperty = source as CSSFragmentBuilderStyleProperty; if (styleProperty != null) { var stylePropertyName = new StylePropertyName(styleProperty.Name, 0); return(new ICSSFragment[] { stylePropertyName, new StylePropertyValue( stylePropertyName, GetValueSections(styleProperty.Value), 0 ) }); } var selectorProperty = source as CSSFragmentBuilderSelector; if (selectorProperty != null) { var selectors = selectorProperty.Selectors; var childFragments = selectorProperty.Children.SelectMany(c => Translate(c, parentSelectors.Concat(new[] { selectorProperty.Selectors }))); ICSSFragment newFragment; if (selectors.First().Value.StartsWith("@media", StringComparison.InvariantCultureIgnoreCase)) { newFragment = new MediaQuery(selectors, parentSelectors, 0, childFragments); } else { newFragment = new Selector(selectors, parentSelectors, 0, childFragments); } return(new[] { newFragment }); } throw new ArgumentException("Unsupported type: " + source.GetType()); }