开发者

Flex: Configure AMF serialization warnings?

I have been trying to test my application to make sure that all the important classes can serialize/reload themselves properly (especially those which implement IExter开发者_如何学Gonalizable):

[Test]
public function testMyObjectSerialization():void {
    var myobj:MyObject = new MyObject();
    var ba:ByteArray = new ByteArray();
    ba.writeObject(myobj);
    ba.position = 0;
    var loadedObj:MyObject = ba.readObject();
    assertMyObjectEqual(myobj, loadedObj);
}

And I would like to be warned when I try to serialize a strongly-typed object which does not have a [RemoteClass] set (because that almost certainly represents a bug in my code).

So, is there any way to configure the AMF serializer to give warnings?

Also, it seems like this might be possible using services-config.xml… But the documentation seems to imply that services-config is channel-level, and I'd really like it if my unit tests could run without talking to the server (and I'm not using LCDS, so a bunch of the services-config wouldn't apply to me anyway).


There is no way to configure the native AMF serialization/deserialization from the Flash Player to give you warnings if [RemoteClass] or any other metadata is set or not.

However you can write your own class to do that - you can register all the objects in a list and check for [Remote] using flash.utils.describeType. Or use a wrapper over writeObject which check for the [Remote] metadata.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜