当它是公司类型时,我需要获取对象项目。 以下是来自相应xsd:
的自动生成的代码 private object itemField;
[System.Xml.Serialization.XmlElementAttribute("Company", typeof(Company), Order=1)]
[System.Xml.Serialization.XmlElementAttribute("Customer", typeof(Customer), Order=1)]
public object Item {
get {
return this.itemField;
}
set {
this.itemField = value;
this.RaisePropertyChanged("Item");
}
}
班级公司如下:
public partial class Company : object, System.ComponentModel.INotifyPropertyChanged {
private string companyNameField;
private CompanyCompanyType companyTypeField;
private string companyIDField;
private string commissionCodeField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=0)]
public string CompanyName {
get {
return this.companyNameField;
}
set {
this.companyNameField = value;
this.RaisePropertyChanged("CompanyName");
}
}
我尝试在我的代码中执行类似的操作:
(Company)Item.CompanyName
但是当Item对象是Type Customer时,这可以是空引用... 你能帮帮我吗?