Exemple #1
0
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            KhronosVersion version = value as KhronosVersion;

            if (version != null)
            {
                if (destinationType == typeof(string))
                {
                    return(version.ToString());
                }
                else if (destinationType == typeof(InstanceDescriptor))
                {
                    ConstructorInfo ctor = typeof(KhronosVersion).GetConstructor(new Type[] {
                        typeof(int), typeof(int), typeof(int), typeof(string), typeof(string)
                    });
                    if (ctor != null)
                    {
                        return(new InstanceDescriptor(ctor, new object[] {
                            version.Major, version.Minor, version.Revision, version.Api, version.Profile
                        }));
                    }
                }
            }
            else
            {
                if (destinationType == typeof(string))
                {
                    return("Current");
                }
            }

            // Base implementation
            return(base.ConvertTo(context, culture, value, destinationType));
        }
Exemple #2
0
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                KhronosVersion version = (KhronosVersion)value;

                if (version == null)
                {
                    return("Current");
                }

                return(version.ToString());
            }

            // Base implementation
            return(base.ConvertTo(context, culture, value, destinationType));
        }