Esempio n. 1
0
        static Exception _TryParse(string text, out MethodName result)
        {
            result = null;

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

            try {
                result = new SignatureParser(text, false, true).ParseMethod();
                return(null);
            } catch (Exception ex) {
                if (Failure.IsCriticalException(ex))
                {
                    throw;
                }
                return(Failure.NotParsable("text", typeof(MethodName)));
            }
        }
Esempio n. 2
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)));
            }
        }
Esempio n. 3
0
        static Exception _TryParse(string text, out PropertyName result)
        {
            result = default(PropertyName);
            if (text == null)
            {
                return(new ArgumentNullException("text"));
            }

            text = text.Trim();
            if (text.Length == 0)
            {
                return(Failure.AllWhitespace("text"));
            }

            try {
                result = new SignatureParser(text).ParseProperty();
            } catch {
            }
            if (result == null)
            {
                return(Failure.NotParsable("text", typeof(PropertyName)));
            }
            return(null);
        }