Last active
January 29, 2017 23:04
-
-
Save PaulDMendoza/1ec5e02c5c3527d1ab7134d202c686c6 to your computer and use it in GitHub Desktop.
Visual Studio Find and Replace to convert auto property to set an "_isDirty" flag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Guid _UserID = Guid.Empty; | |
public Guid UserID { get { return _UserID;} set { _isDirty = true; _UserID = value; } } | |
string _EmailAddress = null; | |
public string EmailAddress { get { return _EmailAddress;} set { _isDirty = true; _EmailAddress = value; } } | |
string _Name = null; | |
public string Name { get { return _Name;} set { _isDirty = true; _Name = value; } } | |
int _TimesFound = 0; | |
public int TimesFound { get { return _TimesFound;} set { _isDirty = true; _TimesFound = value; } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Guid UserID { get; set; } | |
public string EmailAddress { get; set; } | |
public string Name { get; set; } | |
public int TimesFound { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To use this add a property to you class like "public bool _isDirty { get; set; }". Then in Visual Studio just use the find and replace tool and enable Regex. | |
public ([\w?\]\[]+) ([a-zA-Z_]+) { get; set; } | |
$1 _$2 = null; \r\n\t\tpublic $1 $2 { get { return _$2;} set { _isDirty = true; _$2 = value; } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment