/// <summary> /// Converts the input to the outputType using a fast conversion, for known system types. /// </summary> /// <param name="outputType">The target type</param> /// <param name="input">The input value to use</param> /// <param name="output">The input value converted to the <paramref name="outputType"/>.</param> /// <returns>True if the conversion succeeded, otherwise false.</returns> /// <remarks> /// This is a fast path conversion that avoids going through the TypeConverter /// infrastructure for known system types. /// </remarks> private static bool FastConvert(Type outputType, object input, out object output) { output = null; if ( input is string stringInput && FastStringConvert(outputType, stringInput, ref output) ) { return(true); } if (FastNumberConvert(outputType, input, ref output)) { return(true); } return(input switch { Enum _ => FastEnumConvert(outputType, input, ref output), bool boolInput => FastBooleanConvert(outputType, boolInput, ref output), Windows.UI.Color color => FastColorConvert(outputType, color, ref output), SolidColorBrush solidColorBrush => FastSolidColorBrushConvert(outputType, solidColorBrush, ref output), ColorOffset colorOffsetInput => FastColorOffsetConvert(outputType, colorOffsetInput, ref output), Thickness thicknessInput => FastThicknessConvert(outputType, thicknessInput, ref output), _ => false });
partial void OnColorChanged(Windows.UI.Color oldValue, Windows.UI.Color newValue) { UpdateColorWithOpacity(newValue); }
public SolidColorBrush(Windows.UI.Color color) : this() { Color = color; UpdateColorWithOpacity(color); }
/// <remarks> /// This method is required for performance. Creating a native Color /// requires a round-trip with Objective-C, so updating this value only when opacity /// and color changes is more efficient. /// </remarks> private void UpdateColorWithOpacity(Windows.UI.Color newColor) { ColorWithOpacity = GetColorWithOpacity(newColor); }
partial void OnColorChanged(Windows.UI.Color oldValue, Windows.UI.Color newValue);