使用或调用XSD生成的类的正确方法是什么

时间:2014-08-12 21:37:20

标签: c# xml xsd

我想知道如何使用从XSD生成的类,我尝试了几种方法,但我还没有设法让它工作

该类的名称是“LinesList”。

在这里,我将转发我使用它的方式。

LinesListLine var1 = new LinesListLine()

{
 SignalingType = LinesList_SignalingType.Signal1,
 SignalingTypeSpecified = true,
 LineUsageSpecified = true,
 LineUsage = LinesList_LineUsage.Voice,
 ConfiguredSIPBinding = "Test (Demo)"
}

LinesList var2 = new LinesList();
var2.Line = var1; 

(在这一行我得到错误NEXT“无法隐式转换'LinesListLine'到'LinesListLine []”)

This is my Class (Class1.cs)


enter code here
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;
// 
// This source code was auto-generated by wsdl, Version=4.0.30319.33440.
//
//<remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.33440")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttributeNamespace="http://Ejemplo.com")]
public partial class LinesList 
{
private LinesListLine[] lineField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Line")]
public LinesListLine[] Line 
{
get {
       return this.lineField;
      }
set {
      this.lineField = value;
     }
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.33440")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttributeAnonymousType=true,Namespace="http://Ejemplo.com")]
public partial class LinesListLine 
{
private LinesList_SignalingType signalingTypeField;
private bool signalingTypeFieldSpecified;
private string configuredSIPBindingField;
private LinesList_LineUsage lineUsageField;
private bool lineUsageFieldSpecified;
/// <remarks/>
public LinesList_SignalingType SignalingType 
{
  get {
         return this.signalingTypeField;
       }
  set {
         this.signalingTypeField = value;
       }
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool SignalingTypeSpecified 
{
 get {
         return this.signalingTypeFieldSpecified;
       }
 set {
        this.signalingTypeFieldSpecified = value;
      }
}
/// <remarks/>
public string ConfiguredSIPBinding 
{
  get {
          return this.configuredSIPBindingField;
        }
  set  {
         this.configuredSIPBindingField = value;
        }
}
/// <remarks/>
public LinesList_LineUsage LineUsage 
{
 get {
        return this.lineUsageField;
       }
 set {
        this.lineUsageField = value;
       }
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool LineUsageSpecified 
{
 get {
         return this.lineUsageFieldSpecified;
       }
 set {
         this.lineUsageFieldSpecified = value;
       }
}
} 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.33440")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://Ejemplo.com")]
public enum LinesList_SignalingType 
{
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("Signal Type 1")]
Signal1,
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("Signal Type 2")]
Signal2,
/// <remarks/>
Signal3,
/// <remarks/>
None,
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.33440")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute  (Namespace="http://Ejemplo.com")]
public enum LinesList_LineUsage 
{
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("Voice")]
Voice,
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("Fax")]
Fax,
}

0 个答案:

没有答案