Пример #1
0
        static Exception _TryParse(string text, out CodeReference result)
        {
            result = null;
            if (text == null)
            {
                return(new ArgumentNullException("text")); // $NON-NLS-1
            }

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

            int index = text.IndexOf(':');

            if (index < 0)
            {
                result = new UnspecifiedCodeReference(text);
                return(null);
            }

            string specifier = text.Substring(0, index).Trim();
            string name      = text.Substring(index + 1).Trim();

            if (specifier.Length == 1)
            {
                SymbolType type = CodeReferenceHelper.GetReferenceType(specifier[0]);

                if (type != SymbolType.Unknown)
                {
                    result = Create(type, name);
                    return(result.IsValid ? null : Failure.NotParsable("text", typeof(CodeReference)));
                }
            }

            return(Failure.NotParsable("text", typeof(CodeReference)));
        }
Пример #2
0
 public sealed override string ToString()
 {
     return(CodeReferenceHelper.GetReferenceTypeSpecifierChar(SymbolType)
            + ":" + CanonicalString);
 }