XmlSchemaType.GetBuiltInSimpleType 方法

定義

傳回 XmlSchemaSimpleType,表示指定之簡單型別的內建簡單型別。

多載

GetBuiltInSimpleType(XmlTypeCode)

傳回 XmlSchemaSimpleType,表示指定之簡單型別的內建簡單型別。

GetBuiltInSimpleType(XmlQualifiedName)

傳回 XmlSchemaSimpleType,表示限定名稱指定之簡單型別的內建簡單型別。

GetBuiltInSimpleType(XmlTypeCode)

Source:
XmlSchemaType.cs
Source:
XmlSchemaType.cs
Source:
XmlSchemaType.cs

傳回 XmlSchemaSimpleType,表示指定之簡單型別的內建簡單型別。

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

參數

typeCode
XmlTypeCode

其中一個 XmlTypeCode 值,表示簡單型別。

傳回

XmlSchemaSimpleType,表示內建簡單型別。

範例

下列範例示範如何建立型別,並將其新增至架構。

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

備註

您無法直接序列化內建類型。 如果您需要序列化類型,請建立衍生自內建型別並序列化簡單型別的新簡單型別。

適用於

GetBuiltInSimpleType(XmlQualifiedName)

Source:
XmlSchemaType.cs
Source:
XmlSchemaType.cs
Source:
XmlSchemaType.cs

傳回 XmlSchemaSimpleType,表示限定名稱指定之簡單型別的內建簡單型別。

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

參數

qualifiedName
XmlQualifiedName

簡單型別的 XmlQualifiedName

傳回

XmlSchemaSimpleType,表示內建簡單型別。

例外狀況

範例

下列範例示範如何建立型別,並將其新增至架構。

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

備註

您無法直接序列化內建類型。 如果您需要序列化類型,請建立衍生自內建型別並序列化簡單型別的新簡單型別。

適用於