示例#1
0
 /// <summary>
 /// Create deep copy of the css data with cloned css blocks.
 /// </summary>
 /// <returns>cloned object</returns>
 public CssData Clone()
 {
     var clone = new CssData();
     foreach (var mid in _mediaBlocks)
     {
         var cloneMid = new Dictionary<string, List<CssBlock>>(StringComparer.InvariantCultureIgnoreCase);
         foreach (var blocks in mid.Value)
         {
             var cloneList = new List<CssBlock>();
             foreach (var cssBlock in blocks.Value)
             {
                 cloneList.Add(cssBlock.Clone());
             }
             cloneMid[blocks.Key] = cloneList;
         }
         clone._mediaBlocks[mid.Key] = cloneMid;
     }
     return clone;
 }
示例#2
0
        /// <summary>
        /// Combine this CSS data blocks with <paramref name="other"/> CSS blocks for each media.<br/>
        /// Merge blocks if exists in both.
        /// </summary>
        /// <param name="other">the CSS data to combine with</param>
        public void Combine(CssData other)
        {
            ArgChecker.AssertArgNotNull(other, "other");

            // for each media block
            foreach (var mediaBlock in other.MediaBlocks)
            {
                // for each css class in the media block
                foreach (var bla in mediaBlock.Value)
                {
                    // for each css block of the css class
                    foreach (var cssBlock in bla.Value)
                    {
                        // combine with this
                        AddCssBlock(mediaBlock.Key, cssBlock);
                    }
                }
            }
        }