Example #1
0
        private static TypeConverter GetTypeConverter(Type type, MemberInfo member)
        {
            object key = member ?? type;

            lock (MemberToTypeConverter)
            {
                TypeConverter value;
                if (!MemberToTypeConverter.TryGetValue(key, out value))
                {
                    var memberValue = GetConverter(member);
#if WINDOWS_PHONE
                    value = null;
#else
                    value = TypeDescriptor.GetConverter(type);
#endif
                    if (value != null && memberValue != null)
                    {
                        value = new MultiTypeConverter(memberValue, value);
                    }
                    else if (value == null)
                    {
                        value = memberValue;
                    }
                    MemberToTypeConverter[key] = value;
                }
                return(value);
            }
        }
        private static TypeConverter GetTypeConverter(Type type, MemberInfo member)
        {
            MemberInfo key = member ?? type;
            lock (MemberToTypeConverter)
            {
                TypeConverter value;
                if (!MemberToTypeConverter.TryGetValue(key, out value))
                {
                    var memberValue = GetConverter(member);
#if WINDOWS_PHONE || SILVERLIGHT
                    value = GetConverter(type);
#else
                    value = TypeDescriptor.GetConverter(type);
#endif
                    if (value != null && memberValue != null)
                        value = new MultiTypeConverter(memberValue, value);
                    else if (value == null)
                        value = memberValue;
                    MemberToTypeConverter[key] = value;
                }
                return value;
            }
        }