Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
忽略c#生成模型中的XML属性_C#_Xml_Xml Parsing_Xsitype - Fatal编程技术网

忽略c#生成模型中的XML属性

忽略c#生成模型中的XML属性,c#,xml,xml-parsing,xsitype,C#,Xml,Xml Parsing,Xsitype,我已经从下面给出的XML代码以及C#模型生成了一个C#模型,当我尝试转换时,我遇到了如下问题 InvalidOperationException:指定的类型无法识别:name='MetadataNumberValue',在使用以下注释时:您可以从c#类中删除该属性。序列化将忽略类中缺少的XML项。 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

我已经从下面给出的XML代码以及C#模型生成了一个C#模型,当我尝试转换时,我遇到了如下问题


InvalidOperationException:指定的类型无法识别:name='MetadataNumberValue',在使用以下注释时:您可以从c#类中删除该属性。序列化将忽略类中缺少的XML项。

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Metadata xmlns="http://www.samplevm.com/democloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.samplevm.com/schema/ovf" xmlns:ovfenv="http://schemas.dmtf.org/ovf/environment/1" xmlns:vmext="http://www.samplevm.com/democloud/extension/v1.5" xmlns:ns9="http://www.samplevm.com/democloud/versions" href="https://mysiter.com/api/admin/vdc/1234/metadata" type="application/vnd.samplevm.democloud.metadata+xml">
        <Link rel="up" href="https://mysiter.com/api/admin/vdc/1234" type="application/vnd.samplevm.admin.vdc+xml"/>
        <Link rel="up" href="https://mysiter.com/api/admin/vdc/1234" type="application/vnd.samplevm.admin.vdc+json"/>
        <Link rel="add" href="https://mysiter.com/api/admin/vdc/1234/metadata" type="application/vnd.samplevm.democloud.metadata+xml"/>
        <Link rel="add" href="https://mysiter.com/api/admin/vdc/1234/metadata" type="application/vnd.samplevm.democloud.metadata+json"/>
        <MetadataEntry href="https://mysiter.com/api/admin/vdc/1234/metadata/CCLCloud.Reservation" type="application/vnd.samplevm.democloud.metadata.value+xml">
            <Link rel="up" href="https://mysiter.com/api/admin/vdc/1234/metadata" type="application/vnd.samplevm.democloud.metadata+xml"/>
            <Link rel="up" href="https://mysiter.com/api/admin/vdc/1234/metadata" type="application/vnd.samplevm.democloud.metadata+json"/>
            <Link rel="edit" href="https://mysiter.com/api/admin/vdc/1234/metadata/CCLCloud.Reservation" type="application/vnd.samplevm.democloud.metadata.value+xml"/>
            <Link rel="edit" href="https://mysiter.com/api/admin/vdc/1234/metadata/CCLCloud.Reservation" type="application/vnd.samplevm.democloud.metadata.value+json"/>
            <Link rel="remove" href="https://mysiter.com/api/admin/vdc/1234/metadata/CCLCloud.Reservation"/>
            <Key>Reservation1</Key>
            <**TypedValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MetadataNumberValue">**
                <Value>100</Value>
            </TypedValue>
        </MetadataEntry>
        <MetadataEntry href="https://mysiter.com/api/admin/vdc/1234/metadata/CCLCloud.AllocationType" type="application/vnd.samplevm.democloud.metadata.value+xml">
            <Link rel="up" href="https://mysiter.com/api/admin/vdc/1234/metadata" type="application/vnd.samplevm.democloud.metadata+xml"/>
            <Link rel="up" href="https://mysiter.com/api/admin/vdc/1234/metadata" type="application/vnd.samplevm.democloud.metadata+json"/>
            <Link rel="edit" href="https://mysiter.com/api/admin/vdc/1234/metadata/CCLCloud.AllocationType" type="application/vnd.samplevm.democloud.metadata.value+xml"/>
            <Link rel="edit" href="https://mysiter.com/api/admin/vdc/1234/metadata/CCLCloud.AllocationType" type="application/vnd.samplevm.democloud.metadata.value+json"/>
            <Link rel="remove" href="https://mysiter.com/api/admin/vdc/1234/metadata/CCLCloud.AllocationType"/>
            <Key>AllocationType1</Key>
            <TypedValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MetadataStringValue">
                <Value>OnDemand100</Value>
            </TypedValue>
        </MetadataEntry>
    </Metadata>```


// NOTE: Generated code may require at least .NET Framework 4.5 or .NET Core/Standard 2.0.
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.samplevm.com/democloud/v1.5")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://www.samplevm.com/democloud/v1.5", IsNullable = false)]
public partial class Metadata
{

    private MetadataLink[] linkField;

    private MetadataMetadataEntry[] metadataEntryField;

    private string hrefField;

    private string typeField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("Link")]
    public MetadataLink[] Link
    {
        get
        {
            return this.linkField;
        }
        set
        {
            this.linkField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("MetadataEntry")]
    public MetadataMetadataEntry[] MetadataEntry
    {
        get
        {
            return this.metadataEntryField;
        }
        set
        {
            this.metadataEntryField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string href
    {
        get
        {
            return this.hrefField;
        }
        set
        {
            this.hrefField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string type
    {
        get
        {
            return this.typeField;
        }
        set
        {
            this.typeField = value;
        }
    }
}

/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.samplevm.com/democloud/v1.5")]
public partial class MetadataLink
{

    private string relField;

    private string hrefField;

    private string typeField;

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string rel
    {
        get
        {
            return this.relField;
        }
        set
        {
            this.relField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string href
    {
        get
        {
            return this.hrefField;
        }
        set
        {
            this.hrefField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string type
    {
        get
        {
            return this.typeField;
        }
        set
        {
            this.typeField = value;
        }
    }
}

/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.samplevm.com/democloud/v1.5")]
public partial class MetadataMetadataEntry
{

    private MetadataMetadataEntryLink[] linkField;

    private string keyField;

    private MetadataMetadataEntryTypedValue typedValueField;

    private string hrefField;

    private string typeField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("Link")]
    public MetadataMetadataEntryLink[] Link
    {
        get
        {
            return this.linkField;
        }
        set
        {
            this.linkField = value;
        }
    }

    /// <remarks/>
    public string Key
    {
        get
        {
            return this.keyField;
        }
        set
        {
            this.keyField = value;
        }
    }

    /// <remarks/>
    public MetadataMetadataEntryTypedValue TypedValue
    {
        get
        {
            return this.typedValueField;
        }
        set
        {
            this.typedValueField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string href
    {
        get
        {
            return this.hrefField;
        }
        set
        {
            this.hrefField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string type
    {
        get
        {
            return this.typeField;
        }
        set
        {
            this.typeField = value;
        }
    }
}

/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.samplevm.com/democloud/v1.5")]
public partial class MetadataMetadataEntryLink
{

    private string relField;

    private string hrefField;

    private string typeField;

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string rel
    {
        get
        {
            return this.relField;
        }
        set
        {
            this.relField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string href
    {
        get
        {
            return this.hrefField;
        }
        set
        {
            this.hrefField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string type
    {
        get
        {
            return this.typeField;
        }
        set
        {
            this.typeField = value;
        }
    }
}

/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.samplevm.com/democloud/v1.5")]
public partial class MetadataMetadataEntryTypedValue
{

    private string valueField;

    /// <remarks/>
    public string Value
    {
        get
        {
            return this.valueField;
        }
        set
        {
            this.valueField = value;
        }
    }
}