[英]How to generate web service reference without INotifyPropertyChanged?
我在SilverLight项目中使用Fody来自动生成属性依赖项。 但是,如果setter已包含RaisePropertyChanged
方法调用,则它不起作用。
解决方法可能是生成没有INotifyPropertyChanged
Web服务引用代码,而是在部分方法中实现它。
如何在没有INotifyPropertyChanged
情况下生成Web服务引用代码?
我有一个WCF服务,我们称之为MaterialService.svc。 它看起来像这样:
[ServiceContract]
public interface IMaterialService
{
[OperationContract]
Material GetMaterial(int id);
}
[DataContract]
public class Material
{
[DataMember]
public int ID { get; set; }
[DataMember]
public string Name { get; set; }
}
当我将服务添加为服务引用并生成客户端代码时,每个类都设置为实现INotifyPropertyChanged
:
public partial class Material : object, System.ComponentModel.INotifyPropertyChanged {
private int IDField;
private string NameField;
[System.Runtime.Serialization.DataMemberAttribute()]
public int ID {
get {
return this.IDField;
}
set {
if ((this.IDField.Equals(value) != true)) {
this.IDField = value;
this.RaisePropertyChanged("ID");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public System.Nullable<string> Name {
get {
return this.NameField;
}
set {
if ((this.NameField.Equals(value) != true)) {
this.NameField = value;
this.RaisePropertyChanged("Name");
}
}
}
}
如何生成未实现INotifyPropertyChanged
客户端代码?
添加服务引用后,打开服务引用下的Reference.svcmap
文件(可能需要在“项目”菜单中启用“显示所有文件”选项)。 找到<EnableDataBinding>
元素,并将值更改为false。 这将从生成的数据协定中删除INotifyPropertyChanged
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.