Exemplo n.º 1
0
        /// <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
            });
Exemplo n.º 2
0
 partial void OnColorChanged(Windows.UI.Color oldValue, Windows.UI.Color newValue)
 {
     UpdateColorWithOpacity(newValue);
 }
Exemplo n.º 3
0
 public SolidColorBrush(Windows.UI.Color color) : this()
 {
     Color = color;
     UpdateColorWithOpacity(color);
 }
Exemplo n.º 4
0
 /// <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);
 }
Exemplo n.º 5
0
 partial void OnColorChanged(Windows.UI.Color oldValue, Windows.UI.Color newValue);