Esempio n. 1
0
        private static Action <SvgElementStyleData, CssStylePropertyValue> CreateParserAndSetter <T>(Func <string, T> parser, PropertyInfo propertyInfo)
        {
            void Result(SvgElementStyleData style, CssStylePropertyValue value)
            {
                var parsedValue   = value.IsInherit ? default(T) : parser(value.Value);
                var propertyValue = new StyleProperty <T>(parsedValue, isImportant: value.IsImportant);

                propertyInfo.SetValue(style, propertyValue);
            }

            return(Result);
        }
Esempio n. 2
0
        private static Action <SvgElementStyleData, CssStylePropertyValue> CreateParserAndSetterForInheritableNumber(Expression <Func <SvgElementStyleData, StyleProperty <float>?> > propertyResolver)
        {
            var propertyInfo = GetPropertyInfo(propertyResolver);

            void Result(SvgElementStyleData style, CssStylePropertyValue value)
            {
                if (value.IsInherit)
                {
                    propertyInfo.SetValue(style, null);
                }
                else
                {
                    var parsedValue = float.Parse(value.Value, CultureInfo.InvariantCulture);
                    StyleProperty <float>?propertyValue = new StyleProperty <float>(parsedValue, isImportant: value.IsImportant);
                    propertyInfo.SetValue(style, propertyValue);
                }
            }

            return(Result);
        }