public StyleValueProviderResult GetValue(StyleValueProviderContext context) { if (context.Property.PropertyType == typeof(RelativeLength)) { if (context.Values.Length == 1) { if (context.Values[0] is LengthPropertyValue propertyValue) { return(StyleValueProviderResult.Success(ToRelativeLength(propertyValue))); } if (context.Values[0] is StringPropertyValue stringPropertyValue) { if (stringPropertyValue.Value == "fill") { return(StyleValueProviderResult.Success(RelativeLength.Infinity)); } if (stringPropertyValue.Value == "shrink") { return(StyleValueProviderResult.Success(RelativeLength.NaN)); } } } } return(StyleValueProviderResult.Fail); }
public StyleValueProviderResult GetValue(StyleValueProviderContext context) { if (scalarTypes.Contains(context.Property.PropertyType)) { if (context.Values.Length == 1) { if (context.Values[0] is ScalarPropertyValue propertyValue) { return(StyleValueProviderResult.Success(propertyValue.Value)); } } } if (context.Property.PropertyType == typeof(string)) { if (context.Values[0] is StringPropertyValue propertyValue) { if (decimal.TryParse(propertyValue.Value, out decimal value)) { return(StyleValueProviderResult.Success(value)); } } } return(StyleValueProviderResult.Fail); }
public StyleValueProviderResult GetValue(StyleValueProviderContext context) { if (context.Property.PropertyType == typeof(string)) { if (context.Values.Length == 1 && context.Values[0] is StringPropertyValue propertyValue) { return(StyleValueProviderResult.Success(propertyValue.Value)); } } return(StyleValueProviderResult.Fail); }
public StyleValueProviderResult GetValue(StyleValueProviderContext context) { if (context.Property.PropertyType == typeof(TimeSpan)) { if (context.Values.Length == 1) { if (context.Values[0] is TimeSpanPropertyValue propertyValue) { return(StyleValueProviderResult.Success(TimeSpan.FromSeconds(propertyValue.Seconds))); } } } return(StyleValueProviderResult.Fail); }
public StyleValueProviderResult GetValue(StyleValueProviderContext context) { if (context.Property.PropertyType == typeof(LayoutDirection)) { if (context.Values.Length == 1 && context.Values[0] is StringPropertyValue propertyValue) { if (Enum.TryParse(propertyValue.Value, out LayoutDirection layoutDirection)) { return(StyleValueProviderResult.Success(layoutDirection)); } } } return(StyleValueProviderResult.Fail); }