예제 #1
0
        static Exception _TryParse(string text, TypeNameParseOptions options, out TypeName result)
        {
            result = null;

            if (text == null)
            {
                return(new ArgumentNullException("text")); // $NON-NLS-1
            }
            text = text.Trim();
            if (text.Length == 0)
            {
                return(Failure.AllWhitespace("text"));
            }

            bool preferGenericParams = options.HasFlag(TypeNameParseOptions.AssumeGenericParameters);

            try {
                result = new SignatureParser(text, preferGenericParams).ParseType();
                return(null);
            } catch (Exception ex) {
                if (Failure.IsCriticalException(ex))
                {
                    throw;
                }
                return(Failure.NotParsable("text", typeof(TypeName)));
            }
        }
예제 #2
0
        public static TypeName Parse(string text, TypeNameParseOptions options)
        {
            TypeName  result;
            Exception ex = _TryParse(text, options, out result);

            if (ex == null)
            {
                return(result);
            }
            else
            {
                throw ex;
            }
        }
예제 #3
0
 public static bool TryParse(string text, TypeNameParseOptions options, out TypeName result)
 {
     return(_TryParse(text, options, out result) == null);
 }