My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 63: Class members are not populated with cached objects which have a derived type.
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


 
Reported by j...@antitheorystudio.com, Oct 24, 2012
A reference to an object through it's idField will fail to yield the cached object if the member is defined in the class as a base-type of the cached object.

Consider this XML:


  <storyNodes>
    <storyNode id="1">
	Blah blah blah
    </storyNode >
    <storyNode id="2">
	Dum dee dum dee doo
    </storyNode >
  </storyNodes>


  <connections>
    <connection id="3">
      <secondNode id="1"/>
      <firstNode id="2"/>
    </connection>
  </connections>

The storyNode elements represent instances of the StoryNode class which extends Node. 

[...]
public class StoryNode extends Node


The connection elements represent instances of Connection class. 

[...]
public class Connection
{

	[XmlElement(serializePartialElement="true", getFromCache ="true")]
	public var firstNode:Node;
	[XmlElement(serializePartialElement="true", getFromCache ="true")]
	public var secondNode:Node;
...

When you deserialize the XML the Connection object's firstNode and secondNode fields do not reference the StoryNode objects in the cache.

I made a non-elegant workaround for this... In the ObjectCache.isInCache and ObjectCache.getFromCache methods I added the following code.

if (!(clasz in cacheMap)) {
  for (var t:Object in cacheMap) {
	if ((t as Class).prototype instanceof clasz) {
		clasz = t as Class;
		break;
	}
  }
}



Powered by Google Project Hosting