Ejemplo n.º 1
0
        public XamlTypeName ParseName(string text, GenericTypeNamePartDelimeter customeGenericTypeNamePartDelimeter, out string error)
        {
            error           = string.Empty;
            this._scanner   = new GenericTypeNameScanner(text, customeGenericTypeNamePartDelimeter);
            this._inputText = text;
            this.StartStack();
            try
            {
                this._scanner.Read();
                this.P_XamlTypeName();
                if (this._scanner.Token != GenericTypeNameScannerToken.NONE)
                {
                    this.ThrowOnBadInput();
                }
            }
            catch (TypeNameParserException exception)
            {
                error = exception.Message;
            }
            XamlTypeName name = null;

            if (string.IsNullOrEmpty(error))
            {
                name = this.CollectNameFromStack();
            }
            return(name);
        }
Ejemplo n.º 2
0
 internal void ConvertToStringInternal(StringBuilder result, Func <string, string> prefixGenerator)
 {
     if (this.Namespace == null)
     {
         throw new InvalidOperationException(SR.Get("XamlTypeNameNamespaceIsNull"));
     }
     if (string.IsNullOrEmpty(this.Name))
     {
         throw new InvalidOperationException(SR.Get("XamlTypeNameNameIsNullOrEmpty"));
     }
     if (prefixGenerator == null)
     {
         result.Append("{");
         result.Append(this.Namespace);
         result.Append("}");
     }
     else
     {
         string str = prefixGenerator(this.Namespace);
         if (str == null)
         {
             throw new InvalidOperationException(SR.Get("XamlTypeNameCannotGetPrefix", new object[] { this.Namespace }));
         }
         if (str != string.Empty)
         {
             result.Append(str);
             result.Append(":");
         }
     }
     if (this.HasTypeArgs)
     {
         string str2;
         string str3 = GenericTypeNameScanner.StripSubscript(this.Name, out str2);
         result.Append(str3);
         result.Append("(");
         ConvertListToStringInternal(result, this.TypeArguments, prefixGenerator);
         result.Append(")");
         result.Append(str2);
     }
     else
     {
         result.Append(this.Name);
     }
 }