private StyleObject ReadFunction(IStyleSheetLexer lexer, string functionName) { List <StyleObject> functionArgs = new List <StyleObject>(); bool exitLoop = false; while (!exitLoop && lexer.Read(out IStyleSheetLexerToken token)) { switch (token.Type) { case StyleSheetLexerTokenType.Value: functionArgs.Add(new StyleObject(token.Value)); break; case StyleSheetLexerTokenType.Function: functionArgs.Add(ReadFunction(lexer, token.Value)); break; case StyleSheetLexerTokenType.FunctionArgumentsStart: break; case StyleSheetLexerTokenType.FunctionArgumentSeparator: break; case StyleSheetLexerTokenType.FunctionArgumentsEnd: exitLoop = true; break; default: throw new UnexpectedTokenException($"Unexpected token: {token.Type}."); } } StyleObject returnValue = PropertyUtilities.EvaluateFunction(functionName, functionArgs.ToArray(), options.FileReader); if (returnValue.Type == StyleObjectType.Image) { disposableResources.Add(returnValue.GetImage()); } return(returnValue); }
public StyleObject(StyleObject value) { this.Type = value.Type; this.value = value.value; }
// Public members public static IProperty Create(string name, StyleObject value) { return(Create(name, new[] { value })); }
public static IProperty Create(PropertyType type, StyleObject value) { return(Create(type, new[] { value })); }