CanValidate() public method

public CanValidate ( Type type ) : bool
type System.Type
return bool
		public void CanValidate ()
		{
			RegexStringValidator v = new RegexStringValidator ("[0-9]+");

			Assert.IsTrue (v.CanValidate (typeof (string)));
			Assert.IsFalse (v.CanValidate (typeof (int)));
			Assert.IsFalse (v.CanValidate (typeof (object)));
		}
Example #2
0
        public bool IsKnownURIType(string filename)
        {
            bool IsURI = false;
            string expression = Properties.Settings.Default.uriRegex;
            RegexStringValidator rsv = new RegexStringValidator(expression);
            if (rsv.CanValidate(filename.GetType()))
            {
                try
                {
                    rsv.Validate(filename);
                    IsURI = true;
                    log.InfoFormat("Import.isURI: File: {0} is in URI format.", filename);
                }
                catch
                {
                    log.InfoFormat("Import.isURI: File: {0} is not in URI format.", filename);
                    IsURI = false;
                }
            }

            return IsURI;
        }