public void ConvertFrom()
 {
     RegexConverter rc = new RegexConverter();
     object regex = rc.ConvertFrom("[a-z]");
     Assert.IsNotNull(regex);
     Assert.IsTrue(regex is Regex);
     Assert.IsFalse(((Regex)regex).IsMatch("2"));
 }
 /// <summary>
 /// Registers standard and configured type converters.
 /// </summary>
 static TypeConverterRegistry()
 {
     lock (_syncRoot)
     {
         _converters[typeof(string[])] = new StringArrayConverter();
         _converters[typeof(Type)] = new RuntimeTypeConverter();
         _converters[typeof(Uri)] = new UriConverter();
         _converters[typeof(FileInfo)] = new FileInfoConverter();
         _converters[typeof(NameValueCollection)] = new NameValueConverter();
         _converters[typeof(Regex)] = new RegexConverter();
         _converters[typeof(TimeSpan)] = new TimeSpanConverter();
     }
 }
Exemple #3
0
 /// <summary>
 /// Registers standard and configured type converters.
 /// </summary>
 static TypeConverterRegistry()
 {
     lock (_syncRoot)
     {
         _converters[typeof(string[])]            = new StringArrayConverter();
         _converters[typeof(Type)]                = new RuntimeTypeConverter();
         _converters[typeof(Uri)]                 = new UriConverter();
         _converters[typeof(FileInfo)]            = new FileInfoConverter();
         _converters[typeof(NameValueCollection)] = new NameValueConverter();
         _converters[typeof(Regex)]               = new RegexConverter();
         _converters[typeof(TimeSpan)]            = new TimeSpanConverter();
     }
 }
 public void ConvertFromNullReference()
 {
     RegexConverter rc = new RegexConverter();
     rc.ConvertFrom(null);
 }
 public void ConvertFromNonSupportedOptionBails()
 {
     RegexConverter rc = new RegexConverter();
     rc.ConvertFrom(12);
 }