Example #1
0
 public void DumpXml(XmlWriter writer, string elementName)
 {
     writer.WriteStartElement(elementName);
     writer.WriteAttributeString("index", _index.ToString());
     writer.WriteAttributeString("kind", Kind.ToString());
     if (IsParameterizedType)
     {
         if (Type != null)
         {
             writer.WriteAttributeString("type", Type.ToString());
         }
         if (TypeParameter != null)
         {
             writer.WriteAttributeString("param", TypeParameter.ToString());
         }
     }
     else
     {
         if (Name != null)
         {
             writer.WriteAttributeString("name", Name.Value);
         }
         if (Namespace != null)
         {
             writer.WriteAttributeString("ns", Namespace.NameString);
             writer.WriteAttributeString("nskind", Namespace.Kind.ToString());
             writer.WriteAttributeString("nsindex", Namespace.Index.ToString());
         }
         if (NamespaceSet != null)
         {
             writer.WriteAttributeString("nsset", NamespaceSet.Index.ToString());
             //_nsset.DumpXml(writer);
         }
     }
     writer.WriteEndElement();
 }
Example #2
0
 public override string ToString()
 {
     return(TypeParameter?.ToString() ?? base.ToString());
 }
Example #3
0
        public string ToString(string format)
        {
            if (Kind == 0)
            {
                return("*");
            }
            var sb = new StringBuilder();

            if (format == "s")
            {
                string fullname = FullName;
                sb.Append(string.IsNullOrEmpty(fullname) ? Kind.ToString() : fullname);
                return(sb.ToString());
            }

            if (IsQName)
            {
                sb.Append(FullName);
                return(sb.ToString());
            }

            sb.Append(Kind.ToString());
            sb.AppendFormat("[{0}] ", _index);
            sb.Append("{");

            if (IsParameterizedType)
            {
                if (Type != null)
                {
                    sb.Append("type = ");
                    sb.Append(Type.ToString());
                    if (TypeParameter != null)
                    {
                        sb.Append(", param = ");
                        sb.Append(TypeParameter.ToString());
                    }
                }
            }
            else
            {
                if (NamespaceSet != null)
                {
                    sb.Append("nsset[");
                    sb.Append(NamespaceSet.Index);
                    sb.Append("]{");
                    int n = NamespaceSet.Count;
                    for (int i = 0; i < n; ++i)
                    {
                        if (i > 0)
                        {
                            sb.Append("; ");
                        }
                        sb.Append(NamespaceSet[i].ToString("f"));
                    }
                    sb.Append("} ");
                }
                else if (Namespace != null)
                {
                    sb.Append("ns[");
                    sb.Append(Namespace.Index);
                    sb.Append("]{");
                    sb.Append(Namespace.ToString("f"));
                    sb.Append("} ");
                }
                if (Name != null)
                {
                    sb.Append("name = ");
                    sb.Append(Name);
                }
            }
            sb.Append("}");

            return(sb.ToString());
        }