2
我有读起来就像一个WCF服务合同:是否有可能在运行时为Silverlight生成WCF异步服务合同?
[ServiceContract(Name = "DummyService") ]
public interface IDummyService {
[OperationContract]
void DoSomething();
[OperationContract(Name = "SayHello")]
string SayHello(string message);
}
WCF服务将Silverlight应用程序消耗。我正在寻找一种方法来消除手动编写异步合约的需要,这样我就可以通过ChannelFactory生成的代理来使用它。
我想写一个专门的调用者类。样品用法如下:
// create the invoker using the endpoint config and the existing sync contract
var client = new ServiceInvoker<IDummyService>("LeyDummyService_Endpoint");
// invoke the desired service method set the callback, very similar to how
// JQuery does AJAX calls...
client.Invoke(dummyService => dummyService.SayHello("harley"),
(result) => MessageBox.Show(result));
有没有人试过?这甚至有可能吗?
不是一种选择。我讨厌为那些异步契约编写代码,因此是个问题 – leypascua 2011-12-27 07:39:31