我可以更改Silverlight WCF数据服务ServiceReference的T4吗?

时间:2011-09-15 14:30:05

标签: silverlight silverlight-4.0 t4 wcf-data-services

我的网络应用中有一个WCF数据服务。我在Silverlight应用程序中使用“添加新服务引用”命令添加了服务引用。我正在查看VS为我生成的Reference.cs文件,并注意到setter在调用OnPropertyChanged之前没有检查更改。我想改变这种行为。我可以覆盖T4模板而不必覆盖所有代码生成吗? 如果有可能我该怎么做呢?

原始生成的代码

 /// <summary>
 /// There are no comments for Property Title in the schema.
 /// </summary>
 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
 public string Title
 {
    get
    {
         return this._Title;
    }
    set
    {
        this.OnTitleChanging(value);
        this._Title = value;
        this.OnTitleChanged();
        this.OnPropertyChanged("Title");
    }
 }

期望的变化:

  /// <summary>
  /// There are no comments for Property Title in the schema.
  /// </summary>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
  public string Title
  {
     get
     {
         return this._Title;
     }
     set
     {
        // change to 
        if(this._Title != value) {
            this.OnTitleChanging(value);
            this._Title = value;
            this.OnTitleChanged();
            this.OnPropertyChanged("Title");
        }
      }
   }

1 个答案:

答案 0 :(得分:1)

不幸的是,WCF数据服务的添加服务参考尚未使用T4。所以没有简单的方法可以做到这一点。请随意为此功能投票:http://blogs.msdn.com/b/astoriateam/archive/2010/09/10/what-do-you-want-to-see-added-changed-in-wcf-data-services.aspx