1

Closed

Question on AltSerializer.serialize.cs class

description

Hi,
 
I have some question regarding on your implementation in one function of AltSerializer class as following. In the while loop you are trying to SerializeElement with item with its collection data type. I was kind of confused. but I am thinking it should be written as following
 
while (enumerator.MoveNext())
        {
            SerializeElement(enumerator.Current, objectType.GetType());
        }
 
private void SerializeList(object genericObject, Type objectType, ObjectMetaData metaData)
    {            
        IList ilist = genericObject as IList;
        if (ilist == null)
        {
            throw new AltSerializeException("The object type " + objectType.FullName + " does not implement IList.");
        }
 
        IEnumerator enumerator = ilist.GetEnumerator();
        Write((int)ilist.Count);
        while (enumerator.MoveNext())
        {
            SerializeElement(enumerator.Current, objectType);
        }
    }
Closed May 26, 2010 at 8:29 PM by Wobba
AltSerialize will be discarded in the future, so I probably won't fix it.

comments

Wobba wrote May 26, 2010 at 8:28 PM

I did not write AltSerialize, but included it from http://www.codeproject.com/KB/cs/AltSerializer.aspx (noted on the project page).

But it might very well be wrong, but I don't think I will fix it.

When I have time and move this project over to .Net 4.0 I will discard AltSerialize as a serializer and only keep google protocol buffers as an external serializer together with the ones provided with the .net framework.

wrote May 26, 2010 at 8:29 PM

wrote Feb 14, 2013 at 12:12 AM

wrote May 16, 2013 at 5:36 AM