System.Xml.Serialization.SchemaObjectWriter.ToString C# (CSharp) Method

ToString() static private method

static private ToString ( NamespaceList list ) : string
list System.Xml.Schema.NamespaceList
return string
        internal static string ToString(NamespaceList list) {
            if (list == null)
                return null;
            switch (list.Type) {
            case NamespaceList.ListType.Any:
                return "##any";
            case NamespaceList.ListType.Other:
                return "##other";
            case NamespaceList.ListType.Set:
                ArrayList ns = new ArrayList();

                foreach (string s in list.Enumerate) {
                    ns.Add(s);
                }
                ns.Sort();
                StringBuilder sb = new StringBuilder();
                bool first = true;
                foreach (string s in ns) {
                    if (first) {
                        first = false;
                    }
                    else {
                        sb.Append(" ");
                    }
                    if (s.Length == 0) {
                        sb.Append("##local");
                    }
                    else {
                        sb.Append(s);
                    }
                }
                return sb.ToString();

            default:
                return list.ToString();
            }
        }

Usage Example

Example #1
0
 internal static XmlQualifiedName NameOf(XmlSchemaObject o)
 {
     if (o is XmlSchemaAttribute)
     {
         return(((XmlSchemaAttribute)o).QualifiedName);
     }
     else if (o is XmlSchemaAttributeGroup)
     {
         return(((XmlSchemaAttributeGroup)o).QualifiedName);
     }
     else if (o is XmlSchemaComplexType)
     {
         return(((XmlSchemaComplexType)o).QualifiedName);
     }
     else if (o is XmlSchemaSimpleType)
     {
         return(((XmlSchemaSimpleType)o).QualifiedName);
     }
     else if (o is XmlSchemaElement)
     {
         return(((XmlSchemaElement)o).QualifiedName);
     }
     else if (o is XmlSchemaGroup)
     {
         return(((XmlSchemaGroup)o).QualifiedName);
     }
     else if (o is XmlSchemaGroupRef)
     {
         return(((XmlSchemaGroupRef)o).RefName);
     }
     else if (o is XmlSchemaNotation)
     {
         return(((XmlSchemaNotation)o).QualifiedName);
     }
     else if (o is XmlSchemaSequence)
     {
         XmlSchemaSequence s = (XmlSchemaSequence)o;
         if (s.Items.Count == 0)
         {
             return(new XmlQualifiedName(".sequence", Namespace(o)));
         }
         return(NameOf(s.Items[0]));
     }
     else if (o is XmlSchemaAll)
     {
         XmlSchemaAll a = (XmlSchemaAll)o;
         if (a.Items.Count == 0)
         {
             return(new XmlQualifiedName(".all", Namespace(o)));
         }
         return(NameOf(a.Items));
     }
     else if (o is XmlSchemaChoice)
     {
         XmlSchemaChoice c = (XmlSchemaChoice)o;
         if (c.Items.Count == 0)
         {
             return(new XmlQualifiedName(".choice", Namespace(o)));
         }
         return(NameOf(c.Items));
     }
     else if (o is XmlSchemaAny)
     {
         return(new XmlQualifiedName("*", SchemaObjectWriter.ToString(((XmlSchemaAny)o).NamespaceList)));
     }
     else if (o is XmlSchemaIdentityConstraint)
     {
         return(((XmlSchemaIdentityConstraint)o).QualifiedName);
     }
     return(new XmlQualifiedName("?", Namespace(o)));
 }