2

我是 WCF 的新手。我正在寻找多个回调合同的出路,可能或不像下面

[ServiceContract (
CallbackContract = typeof (CallbackContract_1),
CallbackContract = typeof (CallbackContract_2),
CallbackContract = typeof (CallbackContract_3))
]
public interface SomeWcfContract {}

我正在搜索谷歌并找到了出路,就像

interface ICallbackContract1
{...}

interface ICallbackContract2 : ICallbackContract1
{...}

[ServiceContract(CallbackContract = typeof(ICallbackContract1))]
interface IMyBaseContract
{...}

[ServiceContract(CallbackContract = typeof(ICallbackContract2))]
interface IMySubContract : IMyBaseContract
{...}

or

interface ICallbackContract1
{...}
interface ICallbackContract2
{...}
interface ICallbackContract3 : ICallbackContract2,ICallbackContract1
{...}

[ServiceContract(CallbackContract = typeof(ICallbackContract1))]
interface IMyBaseContract1
{...}
[ServiceContract(CallbackContract = typeof(ICallbackContract2))]
interface IMyBaseContract2
{...}
[ServiceContract(CallbackContract = typeof(ICallbackContract3))]
interface IMySubContract : IMyBaseContract1,IMyBaseContract2
{...}

我只需要知道多重回调合同是否有其他出路。谢谢

4

1 回答 1

0

单个服务合同不能有多个回调合同(这是 1:1 关系,回调合同可以为空)。正如您发现的那样,这种替代方案(使用多个“前向”合约,每个合约都有自己的回调合约)应该可以工作,尽管我没有尝试过(您可以编写一个简单的程序来测试它)。

于 2012-10-29T05:03:02.453 回答