Can I change the T4 for a Silverlight WCF Data Service ServiceReference?
I have a WCF Data Service in my web app. I added a service reference using the "Add New Service Reference" command in my Silverlight application. I was looking at the Reference.cs file VS generates for me and noticed the setters don't check for a change before calling OnPropertyChanged. I'd like to change this behavior. Can I overrride the T4 template without having to override all the code generation? If it's possible how would I go about doing it?
original generated code
/// <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");
}
}
Desired change:
/// <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");
}
}
}
Unfortunately the Add Service Reference for WCF Data Services doesn't use T4 yet. So there's no easy way to do this. Feel free to vote for the feature here: http://blogs.msdn.com/b/astoriateam/archive/2010/09/10/what-do-you-want-to-see-added-changed-in-wcf-data-services.aspx
精彩评论