/// <summary> /// 获取缩写形式的样式属性 /// </summary> /// <param name="name">样式属性名</param> /// <param name="style">所有的样式设置</param> /// <returns>返回缩写形式,如果可能</returns> public CssStyleProperty TryGetShorthandProperty(string name, CssStyle style) { if (StyleShorthandRules.Contains(name)) { var rule = StyleShorthandRules[name]; return(rule.TryGetShorthandProperty(style)); } else { return(null); } }
/// <summary> /// 展开 CSS 样式属性的缩写形式 /// </summary> /// <param name="property">样式属性设置</param> /// <returns>展开后的形式,若该设置不是缩写形式,则原样返回</returns> protected virtual IEnumerable <CssStyleProperty> ExtractShorthand(CssStyleProperty property) { lock ( SyncRoot ) { if (StyleShorthandRules.Contains(property.Name)) { return(StyleShorthandRules[property.Name].ExtractProperties(property.Value)); } else { return new[] { property } }; } }
/// <summary> /// 检查指定的样式属性是否为一个缩写形式 /// </summary> /// <param name="name">指定的属性名</param> /// <returns>是否为缩写形式</returns> public bool IsShorthandStyle(string name) { return(StyleShorthandRules.Contains(name)); }