我已经实现了 WCF 服务,我定义了如下同步方法;
[ServiceContract]
public interface IMarketingCampaignType
{
[OperationContract]
List<MarketingCampaignTypeData> GetAllCampaignTypes();
[OperationContract]
MarketingCampaignTypeData GetCampaignTypeByID(int CampaignTypeID);
[OperationContract]
MarketingCampaignTypeData CreateNewCampaignType();
[OperationContract]
MarketingCampaignTypeData EditCampaignType();
[OperationContract]
bool DeleteCampaignType();
}
现在在客户端,当我通过在项目下的 Visual Studio 中选择“添加服务引用”来配置此服务时,会在命名空间“App.Client.Proxies.MarketingCampaignTypeServiceRef”下生成界面
但是当我实现这个接口时,我会为每个实现获得两个方法,一个是同步的,另一个是异步的。我知道在客户端中只有您选择要实现的方法,但我的问题是我可以控制我允许的方法还是只使用一种方法而不是两种方法?
这是服务的接口实现
public class MarketingCampaignTypeClient : IMarketingCampaignType
{
public MarketingCampaignTypeData CreateNewCampaignType()
{
throw new NotImplementedException();
}
public Task<MarketingCampaignTypeData> CreateNewCampaignTypeAsync()
{
throw new NotImplementedException();
}
public bool DeleteCampaignType()
{
throw new NotImplementedException();
}
public Task<bool> DeleteCampaignTypeAsync()
{
throw new NotImplementedException();
}
public MarketingCampaignTypeData EditCampaignType()
{
throw new NotImplementedException();
}
public Task<MarketingCampaignTypeData> EditCampaignTypeAsync()
{
throw new NotImplementedException();
}
public MarketingCampaignTypeData[] GetAllCampaignTypes()
{
throw new NotImplementedException();
}
public Task<MarketingCampaignTypeData[]> GetAllCampaignTypesAsync()
{
throw new NotImplementedException();
}
public MarketingCampaignTypeData GetCampaignTypeByID(int CampaignTypeID)
{
throw new NotImplementedException();
}
public Task<MarketingCampaignTypeData> GetCampaignTypeByIDAsync(int CampaignTypeID)
{
throw new NotImplementedException();
}