My code includes two Classes, ImmMessage and Notify, I need to add an instance of ImmMessage to Notify as shown below. classes code was generated by xsd2code which defined In class Notify element "private System.Xml.XmlElement[] anyField" and it would not accept ImmMessage which is not of the same type, How do I resolve that conflict?
I am getting an error message, Please helpCode:ImmMessage _ImmMessage = new ImmMessage(); Notify _Notify = new Notify(); . . . _Notify.Any.Add(_ImmMessage);
Notify ClassCode:The best overloaded method match for 'System.Collections.Generic.List<System.Xml.XmlElement>.Add(System.Xml.XmlElement)' has some invalid arguments
ImmMessage classCode:[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://nice.com/NICEPerform3/Integrations/V1/HTTP-XML")] [System.Xml.Serialization.XmlRootAttribute(Namespace="http://nice.com/NICEPerform3/Integrations/V1/HTTP-XML", IsNullable=false)] public partial class Notify { private System.Xml.XmlElement[] anyField; /// <remarks/> [System.Xml.Serialization.XmlAnyElementAttribute()] public System.Xml.XmlElement[] Any { get { return this.anyField; } set { this.anyField = value; } } }
Code:[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3082")] [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://nice.com/NICEPerform3/Integrations/V1/IMM")] [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://nice.com/NICEPerform3/Integrations/V1/IMM", IsNullable = false)] [System.Runtime.Serialization.DataContractAttribute(Name = "ImmMessage", Namespace = "http://nice.com/NICEPerform3/Integrations/V1/IMM")] public partial class ImmMessage : EntityBase<ImmMessage> { private static System.Xml.Serialization.XmlSerializer serializer; private static System.Xml.Serialization.XmlSerializer Serializer { get { if ((serializer == null)) { serializer = new System.Xml.Serialization.XmlSerializer(typeof(ImmMessage)); } return serializer; } } [System.Xml.Serialization.XmlElementAttribute("agentStateMessage", typeof(AgentStatusMessage))] [System.Xml.Serialization.XmlElementAttribute("callStateMessage", typeof(CallStateMessage))] [System.Xml.Serialization.XmlElementAttribute("devicePresenceMessage", typeof(DevicePresenceMessage))] [System.Runtime.Serialization.DataMemberAttribute()] public object Item { get; set; } }


Reply With Quote
Bookmarks