Does anyone know how to handle mapping for a class that extends ArrayList? I'm getting a cast exception when I try list or bag.
For example:
Code:
namespace com.test
{
public struct Declarations
{
public const string SchemaVersion = "urn:com.test.schema";
}
[Serializable]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public class AliasTypeCollection : ArrayList
{
public com.test.AliasType Add(com.test.AliasType obj)
{
base.Add(obj);
return obj;
}
public com.test.AliasType Add()
{
return Add(new com.test.AliasType());
}
public void Insert(int index, com.test.AliasType obj)
{
base.Insert(index, obj);
}
public void Remove(com.test.AliasType obj)
{
base.Remove(obj);
}
new public com.test.AliasType this[int index]
{
get { return (com.test.AliasType) base[index]; }
set { base[index] = value; }
}
}
[XmlType(TypeName="AliasType",Namespace=Declarations.SchemaVersion),Serializable]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public class AliasType
{
[XmlElement(ElementName="Type",IsNullable=false,Form=XmlSchemaForm.Qualified,DataType="string",Namespace=Declarations.SchemaVersion)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string __Type;
[XmlIgnore]
public string Type
{
get { return __Type; }
set { __Type = value; }
}
[XmlElement(ElementName="First",IsNullable=false,Form=XmlSchemaForm.Qualified,DataType="string",Namespace=Declarations.SchemaVersion)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string __First;
[XmlIgnore]
public string First
{
get { return __First; }
set { __First = value; }
}
[XmlElement(ElementName="Middle",IsNullable=false,Form=XmlSchemaForm.Qualified,DataType="string",Namespace=Declarations.SchemaVersion)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string __Middle;
[XmlIgnore]
public string Middle
{
get { return __Middle; }
set { __Middle = value; }
}
[XmlElement(ElementName="Last",IsNullable=false,Form=XmlSchemaForm.Qualified,DataType="string",Namespace=Declarations.SchemaVersion)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string __Last;
[XmlIgnore]
public string Last
{
get { return __Last; }
set { __Last = value; }
}
public AliasType()
{
}
}
[XmlType(TypeName="UserType",Namespace=Declarations.SchemaVersion),Serializable]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public class UserType
{
[XmlElement(ElementName="UserId",IsNullable=false,Form=XmlSchemaForm.Qualified,DataType="string",Namespace=Declarations.SchemaVersion)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string __UserId;
[XmlIgnore]
public string UserId
{
get { return __UserId; }
set { __UserId = value; }
}
[XmlElement(ElementName="Name",IsNullable=false,Form=XmlSchemaForm.Qualified,DataType="string",Namespace=Declarations.SchemaVersion)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string __Name;
[XmlIgnore]
public string Name
{
get { return __Name; }
set { __Name = value; }
}
[XmlElement(ElementName="Email",IsNullable=false,Form=XmlSchemaForm.Qualified,DataType="string",Namespace=Declarations.SchemaVersion)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string __Email;
[XmlIgnore]
public string Email
{
get { return __Email; }
set { __Email = value; }
}
[XmlElement(Type=typeof(com.test.AliasType),ElementName="Alias",IsNullable=false,Form=XmlSchemaForm.Qualified,Namespace=Declarations.SchemaVersion)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public AliasTypeCollection __AliasCollection;
[XmlIgnore]
public AliasTypeCollection AliasCollection
{
get
{
if (__AliasCollection == null) __AliasCollection = new AliasTypeCollection();
return __AliasCollection;
}
set {__AliasCollection = value;}
}
public UserType()
{
}
}
[XmlRoot(ElementName="User",Namespace=Declarations.SchemaVersion,IsNullable=false),Serializable]
public class User : com.test.UserType
{
public User() : base()
{
}
}
}