我有一个Flash应用程序(由AS3提供)和一个服务器应用程序(由c#提供)。我使用AMF在它们之间发送和获取消息。但是现在我遇到一个问题,我无法将Action类型的值(包含另一个包含两个List值的对象值)返回给ActionSript。
这是C#程序
public AMFAddressBookResult SyncAddressBook(AMFLogin loginArgs, AMFAddressBook addressBook)
{
var result = new AMFAddressBookResult(API_ID);
AMFReceiver[] receivers = null;
this.GetReceivers(accessKey, out receivers))
AMFGroup[] groups = null;
this.GetGroups(accessKey, out groups))
result.ResultCode = AMFAddressBookResult.Success;
return result; // here I cannot return because the type doesnot match
}
这是每个类的定义
public class AMFAddressBookResult : AMFResult
{
public AMFAddressBookResult()
: this(0)
{
this.AddressBook = new AMFAddressBook();
}
public AMFAddressBookResult(int apiID)
: base(apiID)
{
this.AddressBook = new AMFAddressBook();
}
[DataMember(Name = "addressBook")]
public AMFAddressBook AddressBook
{ get; set; }
//this one cannot work too
//private AMFAddressBook m_AddressBook;
//[DataMember(Name = "addressBook")]
//public AMFAddressBook AddressBook
//{
// get
// {
// return m_AddressBook;
// }
// set
// {
// m_AddressBook = new AMFAddressBook();
// }
//}
}
public class AMFAddressBook
{
public AMFAddressBook()
{
this.m_Receivers = new List<AMFReceiver>();
this.m_Groups = new List<AMFGroup>();
}
private List<AMFReceiver> m_Receivers;
[DataMember(Name = "receiverList")]
public AMFReceiver[] Receivers
{
get
{
return m_Receivers.ToArray();
}
set
{
m_Receivers = new List<AMFReceiver>(value);
}
}
private List<AMFGroup> m_Groups;
[DataMember(Name = "groupList")]
public AMFGroup[] Groups
{
get
{
return m_Groups.ToArray();
}
set
{
m_Groups = new List<AMFGroup>(value);
}
}
}
并且在ActionScript中,上面的方法应该返回到接受对象类型的方法:
private function onCallSyncAddressBook( result:Object ):void
当然我已经定义了每个匹配c#类的类,如AMFAddressBook,AMFAddressBookResult,AMFGroup,AMFReceiver ....在ActionScript中
我想知道为什么c#方法无法返回ActionScript,如果是因为类型不匹配。