I have to communicate 2 WPF application. To communicate, i am using a WCF windows service running on local machine.
当有人要求使用某种服务方法时,服务又要回头。 只有一个反馈接口,所有方法都在其中书写。 但是,有2个世界森林论坛建议没有采用同样的反馈方法。 因此,我被迫采用未使用的方法。
因此,我试图发现,我是否能够在服务上建立2个不同的、独立的接战接口,但可以肯定。 是否有办法这样做?
<>>>>>
我的样本守则:
IDeviceCallBack
public interface ITestCallBack1
{
[OperationContract(IsOneWay = true)]
void Test1();
}
public interface ITestCallBack2
{
[OperationContract(IsOneWay = true)]
void Test2();
}
public interface IDeviceCallback : ITestCallBack1, ITestCallBack2
{ }
IDevice
[ServiceContract(CallbackContract = typeof(ITestCallBack1))]
public interface ITestContract1
{ }
[ServiceContract(CallbackContract = typeof(ITestCallBack2))]
public interface ITestContract2
{ }
[ServiceContract(CallbackContract = typeof(IDeviceCallback))]
public interface IDevice : ITestContract1, ITestContract2
{
[OperationContract]
bool Subscribe();
[OperationContract]
bool Unsubscribe();
}
What I want: WPF1
[CallbackBehaviorAttribute(ConcurrencyMode = ConcurrencyMode.Multiple)]
public partial class MainWindow : Window, ITestCallBack1, IDisposable//,IDeviceCallBack
{
private InstanceContext context;
private DeviceClient deviceClient;
public MainWindow()
{
InitializeComponent();
context = new InstanceContext(this);
deviceClient = new DeviceServiceReference.DeviceClient(context);
}
public void Dispose()
{
deviceClient.Close();
}
public void Test1()
{
throw new NotImplementedException();
}
// Not Wanted
//public void Test2()
//{
// throw new NotImplementedException();
//}
}
WPF2
[CallbackBehaviorAttribute(ConcurrencyMode = ConcurrencyMode.Multiple)]
public partial class MainWindow : Window, ITestCallBack2, IDisposable //,IDeviceCallBack
{
private InstanceContext context;
private DeviceClient deviceClient;
public MainWindow()
{
InitializeComponent();
context = new InstanceContext(this);
deviceClient = new DeviceServiceReference.DeviceClient(context);
}
public void Dispose()
{
deviceClient.Close();
}
// Not Wanted
//public void Test1()
//{
// throw new NotImplementedException();
//}
public void Test2()
{
throw new NotImplementedException();
}
}