Exemple #1
0
        /// <summary>
        /// Parse - this method is called by the type converter to parse a Brush's string
        /// (provided in "value") with the given IFormatProvider.
        /// </summary>
        /// <returns>
        /// A Brush which was created by parsing the "value".
        /// </returns>
        /// <param name="value"> String representation of a Brush.  Cannot be null/empty. </param>
        /// <param name="context"> The ITypeDescriptorContext for this call. </param>
        internal static Brush Parse(string value, ITypeDescriptorContext context)
        {
            Brush             brush;
            IFreezeFreezables freezer = null;

            if (context != null)
            {
                freezer = (IFreezeFreezables)context.GetService(typeof(IFreezeFreezables));
                if ((freezer != null) && freezer.FreezeFreezables)
                {
                    brush = (Brush)freezer.TryGetFreezable(value);
                    if (brush != null)
                    {
                        return(brush);
                    }
                }
            }

            brush = Parsers.ParseBrush(value, System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS, context);

            if ((brush != null) && (freezer != null) && (freezer.FreezeFreezables))
            {
                freezer.TryFreeze(value, brush);
            }

            return(brush);
        }
 Freezable IFreezeFreezables.TryGetFreezable(string value)
 {
     return(_freezer.TryGetFreezable(value));
 }