I forgot to send you the definition of the class ProtocolsList. Here it is
                public class ProtocolsList
                {
                        ArrayList m_protocolsList;

                        public ProtocolsList()
                        {
                                m_protocolsList = new ArrayList();
                        }

                        public void Clear()
                        {
                                m_protocolsList.Clear();
                        }

                        public void AddProtocol(ProtocolsEnum protocol)
                        {
                                for(int i = 0; i < m_protocolsList.Count;
i++)
                                {
                                        ProtocolsEnum pe =
(ProtocolsEnum)m_protocolsList[i];
                                        if(pe.Equals(protocol))
                                        {
                                                return;
                                        }
                                }

                                m_protocolsList.Add(protocol);
                        }

                        public ProtocolsEnum GetProtocol(int idx)
                        {
                                return (ProtocolsEnum)m_protocolsList[idx];
                        }

                        public int Length()
                        {
                                return m_protocolsList.Count;
                        }

                        public bool IsValid()
                        {
                                bool valid = true;

                                for(int i = 0; i < Length(); i++)
                                {
                                        ProtocolsEnum p = GetProtocol(i);

                                        // Checks to see if the value passed
is valid.
                                        if
(!TypeDescriptor.GetConverter(typeof(ProtocolsEnum)).IsValid(p))
                                        {
                                                valid = false;
                                        }
                                }

                                return valid;
                        }

                        public ProtocolsEnum this[int index]
                        {
                                get
                                {
                                        return
(ProtocolsEnum)m_protocolsList[index];
                                }

                                set
                                {
                                        m_protocolsList[index] =
(ProtocolsEnum)value;
                                }
                        }
                }
        }

-----Original Message-----
From: Christoph Schittko [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 04, 2003 12:15 PM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] XML Serialization


>   [System.Xml.Serialization.XmlTypeAttribute(
>     TypeName = "SensorID.Reader.Agile")]
>   public class AgileReaderSettings : IReaderSettings
>   {
>    private int  m_noAntennas;
>    private string m_ipAddress;
>    private int  m_port;
>    private int  m_autoIDTimeout;
>    private int  m_scanTimeout;
>    private ProtocolsList m_protocols;
>                 }
> The problem I am having is that I ccannot serialize the protocols list
> which is an array list of enumerated types. Everything else
> serializes with
> no problems. I am thinking the reason may be because it's a list of
> enumerated types.


I don't think the class you posted will serialize at all? Did you miss
some properties that are present in the original implementation?

What kind of List is the ProtocolsList? Is it derived from CollectionBase?

Enumerated types should not be a problem, but you need to attach
XmlArrayItem or XmlElement attributes to collections to specify the types
the XmlSerializer will encounter inside the collections, unless it's a
strongly typed collection. Your code with the attribute would look
something like:

[System.Xml.Serialization.XmlElement( typeof( ProtocolEnum )]
public ProtocolsList m_protocols;

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML

Reply via email to