Exemplo n.º 1
0
        // Token: 0x06002C38 RID: 11320 RVA: 0x000C8E1C File Offset: 0x000C701C
        private static string CultureInfoFixup(DependencyProperty property, CultureInfo cultureInfo)
        {
            string result = null;
            DPTypeDescriptorContext context       = new DPTypeDescriptorContext(property, cultureInfo);
            TypeConverter           typeConverter = new CultureInfoIetfLanguageTagConverter();

            if (typeConverter.CanConvertTo(context, typeof(string)))
            {
                result = (string)typeConverter.ConvertTo(context, CultureInfo.InvariantCulture, cultureInfo, typeof(string));
            }
            return(result);
        }
Exemplo n.º 2
0
        private static string CultureInfoFixup(DependencyProperty property, CultureInfo cultureInfo)
        {
            string stringValue = null;

            // Parser uses a specific type coverter for converting instances of other types to and from CultureInfo.
            // This class differs from System.ComponentModel.CultureInfoConverter, the default type converter
            // for the CultureInfo class.
            // It uses a string representation based on the IetfLanguageTag property rather than the Name property
            // (i.e., RFC 3066 rather than RFC 1766).
            // In order to guarantee roundtripability of serialized xaml, textrange serialization needs to use
            // this type coverter for CultureInfo types.

            DPTypeDescriptorContext context = new DPTypeDescriptorContext(property, cultureInfo);

            System.ComponentModel.TypeConverter typeConverter = new CultureInfoIetfLanguageTagConverter();

            if (typeConverter.CanConvertTo(context, typeof(string)))
            {
                stringValue = (string)typeConverter.ConvertTo(
                    context, System.Globalization.CultureInfo.InvariantCulture, cultureInfo, typeof(string));
            }
            return(stringValue);
        }