Compartilhar via


XmlSchemaType.GetBuiltInSimpleType Método

Definição

Retorna um XmlSchemaSimpleType que representa o tipo simples interno do tipo simples especificado.

Sobrecargas

GetBuiltInSimpleType(XmlTypeCode)

Retorna um XmlSchemaSimpleType que representa o tipo simples interno do tipo simples especificado.

GetBuiltInSimpleType(XmlQualifiedName)

Retorna um XmlSchemaSimpleType que representa o tipo simples interno do tipo simples especificado pelo nome qualificado.

GetBuiltInSimpleType(XmlTypeCode)

Retorna um XmlSchemaSimpleType que representa o tipo simples interno do tipo simples especificado.

public:
 static System::Xml::Schema::XmlSchemaSimpleType ^ GetBuiltInSimpleType(System::Xml::Schema::XmlTypeCode typeCode);
public static System.Xml.Schema.XmlSchemaSimpleType GetBuiltInSimpleType (System.Xml.Schema.XmlTypeCode typeCode);
static member GetBuiltInSimpleType : System.Xml.Schema.XmlTypeCode -> System.Xml.Schema.XmlSchemaSimpleType
Public Shared Function GetBuiltInSimpleType (typeCode As XmlTypeCode) As XmlSchemaSimpleType

Parâmetros

typeCode
XmlTypeCode

Um dos valores de XmlTypeCode que representam o tipo simples.

Retornos

XmlSchemaSimpleType

O XmlSchemaSimpleType que representa o tipo simples interno.

Exemplos

O exemplo a seguir mostra como criar o tipo e adicioná-lo ao esquema.

using System;
using System.Xml;
using System.Xml.Schema;

namespace GetBuiltInSimpleType
{
    class Program
    {
        static void Main(string[] args)
        {
            XmlSchema schema = new XmlSchema();
            XmlSchemaSimpleType stringType = new XmlSchemaSimpleType();
            stringType.Name = "myString";
            schema.Items.Add(stringType);
            XmlSchemaSimpleTypeRestriction stringRestriction =
                                 new XmlSchemaSimpleTypeRestriction();
            stringRestriction.BaseTypeName =
                                 new XmlQualifiedName("string",
                         "http://www.w3.org/2001/XMLSchema");
            stringType.Content = stringRestriction;
            schema.Write(Console.Out);
        }
    }
}
Imports System.Xml
Imports System.Xml.Schema

Module Module1

    Sub Main()

        Dim schema As XmlSchema = New XmlSchema()
        Dim stringType As XmlSchemaSimpleType = New XmlSchemaSimpleType()
        stringType.Name = "myString"
        schema.Items.Add(stringType)
        Dim stringRestriction As XmlSchemaSimpleTypeRestriction = _
                                 New XmlSchemaSimpleTypeRestriction()
        stringRestriction.BaseTypeName = _
                                 New XmlQualifiedName("string", _
                                 "http://www.w3.org/2001/XMLSchema")
        stringType.Content = stringRestriction
        schema.Write(Console.Out)

    End Sub

End Module

Comentários

Você não pode serializar diretamente o tipo interno. Se você precisar serializar o tipo, crie um novo tipo simples que deriva do tipo interno e serialize o tipo simples.

Aplica-se a

GetBuiltInSimpleType(XmlQualifiedName)

Retorna um XmlSchemaSimpleType que representa o tipo simples interno do tipo simples especificado pelo nome qualificado.

public:
 static System::Xml::Schema::XmlSchemaSimpleType ^ GetBuiltInSimpleType(System::Xml::XmlQualifiedName ^ qualifiedName);
public static System.Xml.Schema.XmlSchemaSimpleType? GetBuiltInSimpleType (System.Xml.XmlQualifiedName qualifiedName);
public static System.Xml.Schema.XmlSchemaSimpleType GetBuiltInSimpleType (System.Xml.XmlQualifiedName qualifiedName);
static member GetBuiltInSimpleType : System.Xml.XmlQualifiedName -> System.Xml.Schema.XmlSchemaSimpleType
Public Shared Function GetBuiltInSimpleType (qualifiedName As XmlQualifiedName) As XmlSchemaSimpleType

Parâmetros

qualifiedName
XmlQualifiedName

O XmlQualifiedName do tipo simples.

Retornos

XmlSchemaSimpleType

O XmlSchemaSimpleType que representa o tipo simples interno.

Exceções

O parâmetro XmlQualifiedName é null.

Exemplos

O exemplo a seguir mostra como criar o tipo e adicioná-lo ao esquema.

using System;
using System.Xml;
using System.Xml.Schema;

namespace GetBuiltInSimpleType
{
    class Program
    {
        static void Main(string[] args)
        {
            XmlSchema schema = new XmlSchema();
            XmlSchemaSimpleType stringType = new XmlSchemaSimpleType();
            stringType.Name = "myString";
            schema.Items.Add(stringType);
            XmlSchemaSimpleTypeRestriction stringRestriction =
                                 new XmlSchemaSimpleTypeRestriction();
            stringRestriction.BaseTypeName =
                                 new XmlQualifiedName("string",
                         "http://www.w3.org/2001/XMLSchema");
            stringType.Content = stringRestriction;
            schema.Write(Console.Out);
        }
    }
}
Imports System.Xml
Imports System.Xml.Schema

Module Module1

    Sub Main()

        Dim schema As XmlSchema = New XmlSchema()
        Dim stringType As XmlSchemaSimpleType = New XmlSchemaSimpleType()
        stringType.Name = "myString"
        schema.Items.Add(stringType)
        Dim stringRestriction As XmlSchemaSimpleTypeRestriction = _
                                 New XmlSchemaSimpleTypeRestriction()
        stringRestriction.BaseTypeName = _
                                 New XmlQualifiedName("string", _
                                 "http://www.w3.org/2001/XMLSchema")
        stringType.Content = stringRestriction
        schema.Write(Console.Out)

    End Sub

End Module

Comentários

Você não pode serializar diretamente o tipo interno. Se você precisar serializar o tipo, crie um novo tipo simples que deriva do tipo interno e serialize o tipo simples.

Aplica-se a