Microsoft.Tools.WindowsInstaller.ReinstallModesConverter.ConvertTo C# (CSharp) Method

ConvertTo() public method

Converts a ReinstallModes to a short form String like "omus".
public ConvertTo ( ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType ) : object
context ITypeDescriptorContext Additional context for conversion.
culture System.Globalization.CultureInfo The culture to use for conversion.
value object The to convert.
destinationType System.Type The type of the destination object.
return object
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (null != value && this.CanConvertTo(context, destinationType))
            {
                string s = string.Empty;
                ReinstallModes mode = (ReinstallModes)value;

                // Return the REINSTALLMODE property value form.
                foreach (ReinstallModes val in Enum.GetValues(typeof(ReinstallModes)))
                {
                    if (0 != (val & mode))
                    {
                        s += ModeToCharMap[val];
                    }
                }

                return s;
            }

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

Usage Example

        public void ConvertReinstallModesToShortForm()
        {
            var converter = new ReinstallModesConverter();
            Assert.IsTrue(converter.CanConvertTo(typeof(string)));

            var mode = (string)converter.ConvertTo(Default, typeof(string));
            Assert.AreEqual("omus", mode);
        }
All Usage Examples Of Microsoft.Tools.WindowsInstaller.ReinstallModesConverter::ConvertTo