Прочетете на английски Редактиране

Споделяне чрез


XmlSchemaType.GetBuiltInSimpleType Method

Definition

Returns an XmlSchemaSimpleType that represents the built-in simple type of the specified simple type.

Overloads

GetBuiltInSimpleType(XmlTypeCode)

Returns an XmlSchemaSimpleType that represents the built-in simple type of the specified simple type.

GetBuiltInSimpleType(XmlQualifiedName)

Returns an XmlSchemaSimpleType that represents the built-in simple type of the simple type that is specified by the qualified name.

GetBuiltInSimpleType(XmlTypeCode)

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

Returns an XmlSchemaSimpleType that represents the built-in simple type of the specified simple type.

C#
public static System.Xml.Schema.XmlSchemaSimpleType GetBuiltInSimpleType(System.Xml.Schema.XmlTypeCode typeCode);

Parameters

typeCode
XmlTypeCode

One of the XmlTypeCode values representing the simple type.

Returns

The XmlSchemaSimpleType that represents the built-in simple type.

Examples

The following example shows how to create the type and add it to the schema.

C#
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);
        }
    }
}

Remarks

You cannot directly serialize the built-in type. If you need to serialize the type, create a new simple type which derives from the built-in type and serialize the simple type.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

GetBuiltInSimpleType(XmlQualifiedName)

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

Returns an XmlSchemaSimpleType that represents the built-in simple type of the simple type that is specified by the qualified name.

C#
public static System.Xml.Schema.XmlSchemaSimpleType? GetBuiltInSimpleType(System.Xml.XmlQualifiedName qualifiedName);
C#
public static System.Xml.Schema.XmlSchemaSimpleType GetBuiltInSimpleType(System.Xml.XmlQualifiedName qualifiedName);

Parameters

qualifiedName
XmlQualifiedName

The XmlQualifiedName of the simple type.

Returns

The XmlSchemaSimpleType that represents the built-in simple type.

Exceptions

The XmlQualifiedName parameter is null.

Examples

The following example shows how to create the type and add it to the schema.

C#
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);
        }
    }
}

Remarks

You cannot directly serialize the built-in type. If you need to serialize the type, create a new simple type which derives from the built-in type and serialize the simple type.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1