.net - WCF Datacontract free serialization (3.5 SP1) -
has got work? documentation non existent on how enable feature , missing attribute exceptions despite having 3.5 sp1 project.
i found doesn't work internal/private types, making type public worked fine. means no anonymous types either :(
using reflector found method classdatacontract.isnonattributedtypevalidforserialization(type) seems make decision. it's last line seems killer, type must visible, no internal/private types allowed :(
internal static bool isnonattributedtypevalidforserialization(type type) { if (type.isarray) { return false; } if (type.isenum) { return false; } if (type.isgenericparameter) { return false; } if (globals.typeofixmlserializable.isassignablefrom(type)) { return false; } if (type.ispointer) { return false; } if (type.isdefined(globals.typeofcollectiondatacontractattribute, false)) { return false; } foreach (type type2 in type.getinterfaces()) { if (collectiondatacontract.iscollectioninterface(type2)) { return false; } } if (type.isserializable) { return false; } if (globals.typeofiserializable.isassignablefrom(type)) { return false; } if (type.isdefined(globals.typeofdatacontractattribute, false)) { return false; } if (type == globals.typeofextensiondataobject) { return false; } if (type.isvaluetype) { return type.isvisible; } return (type.isvisible && (type.getconstructor(bindingflags.nonpublic | bindingflags.public | bindingflags.instance, null, globals.emptytypearray, null) != null));
}
Comments
Post a Comment