Is it possible to receive custom generic typed objects through AMF? I'm trying to integrate a flex app with an existing C# service but flex is choking on custom generic typed objects. As far as I can tell Flex doesn't even support generics, but I'd like to be able to even just read in the object and cast its members as necessary. I basically just want flex to ignore the <T>
. I'm hopeful that there's a way to do this, since flex doesn't complain about typed collections (a server call returning List works fine and flex converts it to an ArrayCollection just like an un-typed List).
Here's a trimmed down example of what's going on for me:
The custom C# typed class
public class TypeTest<T>
{
public T value { get; set; }
public TypeTest ()
{
}
}
The server method returning the typeTest
public TypeTest<String> doTypeTest()
{
TypeTest<String> theTester = new TypeTest<String>("grrrr");
return theTester;
}
The corresponding flex value object:
[RemoteClass(alias="API.Model.TypeTest")]
public class TypeTest
{
private var _value:Object;
public function get value():Object
{
return _value;
}
public function set value(theValue:Object):void
{
_value = value;
}
public function TypeTest()
{
}
}
and the result handler code:
public function doTypeTest(result:TypeTest):void
{
var theString:String = result.value as String;
trace(theString);
}
When the result handler is called I get the runtime error:
TypeError: Error #1034: Type Coercion failed: cannot convert mx.utils::ObjectProxy@11a98041 to com.model.vos.TypeTest.
Irritatingly if I change the result handler to take parameter of type Object it works fine.
Anyone know how to make this work with the value object? I feel like i'm missing something really obvious.