我在中注意到支持IList<>,但我得到了“无法创建接口实例”的异常。如果我转到IEnumerable<>,那么生活就是美好的。这听起来对吗?
// Client call
public override IList<IApplicationWorkflow> Execute(IRoleManagement service)
{
IList<ApplicationWorkflowMessagePart> list = service.RetrieveWorkflows(roleNames);
IList<IApplicationWorkflow> workflows = new List<IApplicationWorkflow>(list.Count);
foreach (ApplicationWorkflowMessagePart a in list)
{
workflows.Add(new ApplicationWorkflowImpl(a));
}
return workflows;
}
// Service contract
[OperationContract, ProtoBehavior]
[ServiceKnownType(typeof (ServiceFault))]
[FaultContract(typeof (ServiceFault))]
IList<ApplicationWorkflowMessagePart> RetrieveWorkflows(string[] roleNames);
// Service implementation
public IList<ApplicationWorkflowMessagePart> RetrieveWorkflows(string[] roleNames)
{
IList<IApplicationWorkflow> workflows = manager.RetrieveApplicationWorkflows(roleNames);
IList<ApplicationWorkflowMessagePart> workflowParts = new List<ApplicationWorkflowMessagePart>();
if (workflows != null)
{
foreach (IApplicationWorkflow workflow in workflows)
{
workflowParts.Add(
ModelMediator.GetMessagePart<ApplicationWorkflowMessagePart, IApplicationWorkflow>(workflow));
}
}
return workflowParts;
}谢谢你,迈克
另外,是否有文档站点有这个和其他答案?我讨厌问新来的问题。:)
发布于 2009-08-06 21:42:21
目前,它将支持IList<T>作为一个属性,只要它不需要创建它--即允许这样的东西(属性不显示为简洁):
class Order {
private IList<OrderLine> lines = new List<OrderLine>();
public IList<OrderLine> Lines {get {return lines;}}
}我必须检查一下,但出于类似的原因,我希望它能与Merge一起工作,而不是Deserialize (这是WCF挂钩所使用的)。但是,我想不出为什么它不能默认为List<T>.只是暂时不行。
最简单的选择可能是坚持使用List<T> / T[] --但是如果你想要的话,我可以看看.但我目前在一个(工作)项目上处于“紧要关头”,所以今天我不能提起帽子。
关于“这个和其他答案”..。有一个谷歌集团,但这不仅仅是protobuf(protobuf只是许多“协议缓冲区”实现中的一个)。
您也可以在工程场地上记录问题。我的意思是整理常见问题并将它们添加到网站上的wiki中--但时间并不总是我的朋友.
但是嘿!我在这里..。;-p
https://stackoverflow.com/questions/1241535
复制相似问题