Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public StyleObject(StyleObject value)
 {
     this.Type  = value.Type;
     this.value = value.value;
 }
Esempio n. 3
0
        // Public members

        public static IProperty Create(string name, StyleObject value)
        {
            return(Create(name, new[] { value }));
        }
Esempio n. 4
0
 public static IProperty Create(PropertyType type, StyleObject value)
 {
     return(Create(type, new[] { value }));
 }