Exemplo n.º 1
0
 public CssBlockCollection(CssBlockCollection other)
 {
     ArgChecker.AssertArgNotNull(other, nameof(other));
     foreach (var item in other._items)
     {
         _items.Add(item.Key, new List <CssBlock>(item.Value));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Add the given css block to the css data, merging to existing block if required.
        /// </summary>
        /// <remarks>
        /// If there is no css blocks for the same class it will be added to data collection.<br/>
        /// If there is already css blocks for the same class it will check for each existing block
        /// if the hierarchical selectors match (or not exists). if do the two css blocks will be merged into
        /// one where the new block properties overwrite existing if needed. if the new block doesn't mach any
        /// existing it will be added either to the beginning of the list if it has no  hierarchical selectors or at the end.<br/>
        /// Css block without hierarchical selectors must be added to the beginning of the list so more specific block
        /// can overwrite it when the style is applied.
        /// </remarks>
        /// <param name="key">Key of @rule to which css block is to be added</param>
        /// <param name="cssBlock">the css block to add</param>
        internal void AddCssBlock(string key, CssBlock cssBlock)
        {
            key = EnsureKey(key);

            CssBlockCollection item;

            if (!_items.TryGetValue(key, out item))
            {
                item = new CssBlockCollection();
                _items.Add(key, item);
            }
            item.Add(cssBlock);
        }
Exemplo n.º 3
0
        internal void MergeWith(CssNestedBlockCollection other)
        {
            foreach (var otherItem in other._items)
            {
                CssBlockCollection item;
                if (!_items.TryGetValue(otherItem.Key, out item))
                {
                    item = new CssBlockCollection(otherItem.Value);
                    _items.Add(otherItem.Key, item);
                    return;
                }

                item.MergeWith(otherItem.Value);
            }
        }
Exemplo n.º 4
0
        internal void MergeWith(CssBlockCollection other)
        {
            foreach (var otherItem in other._items)
            {
                List <CssBlock> existingBlocks;
                if (!_items.TryGetValue(otherItem.Key, out existingBlocks))
                {
                    existingBlocks = new List <CssBlock>(otherItem.Value);
                    _items.Add(otherItem.Key, existingBlocks);
                    return;
                }

                foreach (var cssBlock in otherItem.Value)
                {
                    Add(cssBlock);
                }
            }
        }