public IPropertyValue Construct(CssProperty[] properties) { var valueList = new List<List<CssToken>>[properties.Length]; var dummies = new CssProperty[properties.Length]; var max = 0; for (var i = 0; i < properties.Length; i++) { var value = properties[i].DeclaredValue; valueList[i] = value != null ? value.Original.ToList() : new List<List<CssToken>>(); dummies[i] = Factory.Properties.CreateLonghand(properties[i].Name); max = Math.Max(max, valueList[i].Count); } var values = new IPropertyValue[max]; for (var i = 0; i < max; i++) { for (var j = 0; j < dummies.Length; j++) { var list = valueList[j]; var tokens = list.Count > i ? list[i] : Enumerable.Empty<CssToken>(); dummies[j].TrySetValue(new CssValue(tokens)); } var converter = (i < max - 1) ? _listConverter : _endConverter; values[i] = converter.Construct(dummies); } return new ListValue(values, Enumerable.Empty<CssToken>()); }
public void Export(CssProperty[] properties) { foreach (var property in properties) { var value = DeclaredValue.ExtractFor(property.Name); property.TrySetValue(value); } }
protected static String SerializePeriodic(CssProperty t, CssProperty r, CssProperty b, CssProperty l) { var top = t.SerializeValue(); var right = r.SerializeValue(); var bottom = b.SerializeValue(); var left = l.SerializeValue(); return(SerializePeriodic(top, right, bottom, left)); }
internal void SetProperty(CssProperty property) { foreach (var declaration in Declarations) { if (declaration.Name.Is(property.Name)) { ReplaceChild(declaration, property); return; } } AppendChild(property); }
internal void SetProperty(CssProperty property) { for (int i = 0; i < _declarations.Count; i++) { if (_declarations[i].Name == property.Name) { _declarations[i] = property; return; } } _declarations.Add(property); }
public IPropertyValue Construct(CssProperty[] properties) { if (properties.Length == 4) { var options = new IPropertyValue[4]; options[0] = _converter.Construct(properties.Where(m => m.Name == _labels[0]).ToArray()); options[1] = _converter.Construct(properties.Where(m => m.Name == _labels[1]).ToArray()); options[2] = _converter.Construct(properties.Where(m => m.Name == _labels[2]).ToArray()); options[3] = _converter.Construct(properties.Where(m => m.Name == _labels[3]).ToArray()); return options[0] != null && options[1] != null && options[2] != null && options[3] != null ? new PeriodicValue(options, Enumerable.Empty<CssToken>(), _labels) : null; } return null; }
public IPropertyValue Construct(CssProperty[] properties) { if (properties.Length == 4) { var front = new List<CssToken>(); var back = new List<CssToken>(); var props = new List<CssProperty> { properties.First(m => m.Name.Is(PropertyNames.BorderTopLeftRadius)), properties.First(m => m.Name.Is(PropertyNames.BorderTopRightRadius)), properties.First( m => m.Name.Is(PropertyNames.BorderBottomRightRadius)), properties.First( m => m.Name.Is(PropertyNames.BorderBottomLeftRadius)) }; for (var i = 0; i < props.Count; i++) { var dpv = props[i].DeclaredValue as IEnumerable<IPropertyValue>; if (dpv == null) { return null; } var first = dpv.First().Original; var second = dpv.Last().Original; if (i != 0) { front.Add(CssToken.Whitespace); back.Add(CssToken.Whitespace); } front.AddRange(first); back.AddRange(second); } var h = _converter.Convert(front); var v = _converter.Convert(back); var o = front.Concat(new CssToken(CssTokenType.Delim, "/", TextPosition.Empty)).Concat(back); return new BorderRadiusValue(h, v, new CssValue(o)); } return null; }
public IPropertyValue Construct(CssProperty[] properties) { var filtered = properties.Where(m => _labels.Contains(m.Name)); var existing = default(String); foreach (var filter in filtered) { var value = filter.Value; if (existing != null && value != existing) return null; existing = value; } var result = _converter.Construct(filtered.Take(1).ToArray()); return result != null ? new TransformationValueConverter(result, _labels) : null; }
public IPropertyValue Construct(CssProperty[] properties) { var result = properties.Guard<OptionsValue>(); if (result == null) { var values = new IPropertyValue[_converters.Length]; for (var i = 0; i < _converters.Length; i++) { var value = _converters[i].Construct(properties); if (value == null) return null; values[i] = value; } result = new OptionsValue(values, Enumerable.Empty<CssToken>()); } return result; }
public IPropertyValue Construct(CssProperty[] properties) { var result = properties.Guard<MultipleValue>(); if (result == null) { var values = new IPropertyValue[properties.Length]; for (var i = 0; i < properties.Length; i++) { var value = _converter.Construct(new[] { properties[i] }); if (value == null) return null; values[i] = value; } result = new MultipleValue(values, Enumerable.Empty<CssToken>()); } return result; }
void SetLonghand(CssProperty property) { for (int i = 0; i < _declarations.Count; i++) { if (_declarations[i].Name == property.Name) { _declarations.RemoveAt(i); break; } else if (_declarations[i] == property) { return; } } _declarations.Add(property); }
public IPropertyValue Construct(CssProperty[] properties) { return properties.Guard<StringsValue>(); }
public DeclarationCondition(CssProperty property, ICssValue value) { _property = property; _value = value; }
public IPropertyValue Construct(CssProperty[] properties) { return _previous.Construct(properties) ?? _next.Construct(properties); }
public String Stringify(CssProperty[] properties) { return Converter.Construct(properties)?.CssText; }
public IPropertyValue Construct(CssProperty[] properties) { return _converter.Construct(properties) ?? new OptionValue(Enumerable.Empty<CssToken>()); }
public IPropertyValue Construct(CssProperty[] properties) { return properties.Guard<ArgumentsValue>(); }
public IPropertyValue Construct(CssProperty[] properties) { var value = _converter.Construct(properties); return value != null ? CreateFrom(value, Enumerable.Empty<CssToken>()) : null; }
public IPropertyValue Construct(CssProperty[] properties) { return properties.Guard<FunctionValue>(); }
public DeclarationCondition(CssProperty property, CssValue value) { _property = property; _value = value; }
public IPropertyValue Construct(CssProperty[] properties) { return properties.Guard<IdentifierValue>(); }
public IPropertyValue Construct(CssProperty[] properties) { return properties.Guard<GradientValue>(); }
internal void SetProperty(CssProperty property) { if (property is CssShorthandProperty) SetShorthand((CssShorthandProperty)property); else SetLonghand(property); }
void SetLonghand(CssProperty property) { foreach (var declaration in Declarations) { if (declaration.Name.Is(property.Name)) { RemoveChild(declaration); break; } } AppendChild(property); }
public IPropertyValue Construct(CssProperty[] properties) { return _converter.Construct(properties); }
public String Stringify(CssProperty[] properties) { var value = Converter.Construct(properties); return value != null ? value.CssText : null; }