CanConvertFrom() public méthode

Returns True when sourceType is a String.
public CanConvertFrom ( ITypeDescriptorContext context, Type sourceType ) : bool
context ITypeDescriptorContext Additional context for conversion.
sourceType System.Type The type of the source object.
Résultat bool
        public void ConvertShortFormToReinstallModes()
        {
            var converter = new ReinstallModesConverter();
            Assert.IsTrue(converter.CanConvertFrom(typeof(string)));

            var mode = (ReinstallModes)converter.ConvertFrom("omUS");
            Assert.AreEqual(Default, mode);
        }
        public void ConvertInvalidStringToReinstallModes()
        {
            var converter = new ReinstallModesConverter();
            Assert.IsTrue(converter.CanConvertFrom(typeof(string)));

            // Should throw ArgumentException.
            var mode = (ReinstallModes)converter.ConvertFrom("xyz");
        }
        public void ConvertNamesToReinstallModes()
        {
            var converter = new ReinstallModesConverter();
            Assert.IsTrue(converter.CanConvertFrom(typeof(string)));

            // Use mixed case to test case-insensitivity.
            var mode = (ReinstallModes)converter.ConvertFrom("FileOlderVersion, MachineData, userData, shortcut");
            Assert.AreEqual(Default, mode);
        }
        public void ConvertInvalidStringToReinstallModes()
        {
            var converter = new ReinstallModesConverter();

            Assert.IsTrue(converter.CanConvertFrom(typeof(string)));

            // Should throw ArgumentException.
            var mode = (ReinstallModes)converter.ConvertFrom("xyz");
        }
        public void ConvertShortFormToReinstallModes()
        {
            var converter = new ReinstallModesConverter();

            Assert.IsTrue(converter.CanConvertFrom(typeof(string)));

            var mode = (ReinstallModes)converter.ConvertFrom("omUS");

            Assert.AreEqual(Default, mode);
        }
        public void ConvertNamesToReinstallModes()
        {
            var converter = new ReinstallModesConverter();

            Assert.IsTrue(converter.CanConvertFrom(typeof(string)));

            // Use mixed case to test case-insensitivity.
            var mode = (ReinstallModes)converter.ConvertFrom("FileOlderVersion, MachineData, userData, shortcut");

            Assert.AreEqual(Default, mode);
        }