/// <summary> /// Called before the property name has been detected. /// </summary> public void CreateDeclarationWith(ICssProperties properties, ref CssToken token) { CollectTrivia(ref token); var start = token.Position; if (token.IsNot(CssTokenType.EndOfFile, CssTokenType.CurlyBracketClose, CssTokenType.Colon) && token.IsNot(CssTokenType.Semicolon, CssTokenType.CurlyBracketOpen)) { var name = token.Data; while (token.Type == CssTokenType.Delim) { token = NextToken(); name += token.Data; } token = NextToken(); CollectTrivia(ref token); if (token.Type == CssTokenType.Colon) { token = NextToken(); CollectTrivia(ref token); var value = CreateValue(ref token, out var important); if (String.IsNullOrEmpty(value)) { RaiseErrorOccurred(CssParseError.ValueMissing, token.Position); } else { properties.SetProperty(name, value, important ? CssKeywords.Important : null); } } else { RaiseErrorOccurred(CssParseError.ColonMissing, token.Position); } JumpToDeclEnd(ref token); } else if (token.Type != CssTokenType.EndOfFile) { RaiseErrorOccurred(CssParseError.IdentExpected, start); JumpToDeclEnd(ref token); } if (token.Type == CssTokenType.Semicolon) { token = NextToken(); } }
public static ICssProperties WithStyle(this ICssProperties cssProperties, string name, string value) { cssProperties.WithStyle(name, new TextCssStyleValue(value)); return(cssProperties); }
public static ICssProperties WithlStyleInPixelUnit(this ICssProperties cssClass, string styleName, int value) { cssClass.WithStyle(styleName, new NumberCssStyleValue(value, CssUnits.Px)); return(cssClass); }