示例#1
0
        public StyleContainer Compute(AbstractElement element)
        {
            BitArray array;

            lock (computedStyles)
            {
                if (selectorCount < 0)
                {
                    selectorCount = styles.Count();
                }

                array = new BitArray(selectorCount);
            }

            int index = 0;

            foreach (var container in styles)
            {
                array.Set(index++, container.Selector.Matches(element));
            }

            if (computedStyles.TryGetValue(array, out var computedContainer))
            {
                return(computedContainer);
            }
            else
            {
                var container = new StyleContainer(AllStyleSelector.Singleton);

                foreach (var styleContainer in styles)
                {
                    if (styleContainer.Selector.Matches(element))
                    {
                        foreach (var(key, value) in styleContainer)
                        {
                            container.Set(key, value);
                        }
                    }
                }

                computedStyles[array] = container;
                return(container);
            }
        }
示例#2
0
 public abstract void Set(StyleContainer style, [DisallowNull] T value);
示例#3
0
 public override void Set(StyleContainer style, [DisallowNull] T value)
 {
     Setter(style, value);
 }
示例#4
0
 public override void Set(StyleContainer style, [DisallowNull] T value)
 {
     style.Set(Name, value);
 }