Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anonymous types are not serialized properly. #28

Open
GoogleCodeExporter opened this issue Jun 29, 2015 · 0 comments
Open

Anonymous types are not serialized properly. #28

GoogleCodeExporter opened this issue Jun 29, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

The class definition is not used when serializing. Instead it creates a blank 
class definition and serializes the members as dynamic. A simple fix is to add 
a class definition field to ASObject and set/use it when dealing with an 
anonymous type.

internal object ReadAMF3Object(ClassDefinition classDefinition)
{
    object instance = null;
    if (!string.IsNullOrEmpty(classDefinition.ClassName))
        instance = ObjectFactory.CreateInstance(classDefinition.ClassName);
    else
        instance = new ASObject() { ClassDefinition = classDefinition }; //This is an anonymous type. Store the class definition for when serializing.



private ClassDefinition GetClassDefinition(object obj)
{
    ClassDefinition classDefinition = null;
    if (obj is ASObject)
    {
        ASObject asObject = obj as ASObject;

        if (asObject.ClassDefinition != null) //Definition was set, that means this is an anonymous type. Return the ClassDefinition property.
            return asObject.ClassDefinition;

Original issue reported on code.google.com by High...@gmail.com on 10 Dec 2011 at 4:19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant