Created
September 30, 2012 04:34
-
-
Save distantcam/3805842 to your computer and use it in GitHub Desktop.
INPC Weaver example
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 class SomeViewModel : INotifyPropertyChanged | |
{ | |
private string <URL>k__BackingField; | |
public event PropertyChangedEventHandler PropertyChanged; | |
public string URL | |
{ | |
[CompilerGenerated] | |
get | |
{ | |
return this.<URL>k__BackingField; | |
} | |
[CompilerGenerated] | |
set | |
{ | |
if (string.Equals(this.<URL>k__BackingField, value, StringComparison.Ordinal)) | |
{ | |
return; | |
} | |
this.<URL>k__BackingField = value; | |
this.OnPropertyChanged("HostName"); | |
this.OnPropertyChanged("URL"); | |
} | |
} | |
public string HostName | |
{ | |
get | |
{ | |
string result; | |
try | |
{ | |
Uri typedURL = new Uri(this.URL); | |
result = typedURL.Host; | |
} | |
catch (UriFormatException) | |
{ | |
result = ""; | |
} | |
return result; | |
} | |
} | |
public virtual void OnPropertyChanged(string propertyName) | |
{ | |
PropertyChangedEventHandler propertyChanged = this.PropertyChanged; | |
if (propertyChanged != null) | |
{ | |
propertyChanged(this, new PropertyChangedEventArgs(propertyName)); | |
} | |
} | |
} |
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 class SomeViewModel : INotifyPropertyChanged | |
{ | |
public string URL { get; set; } | |
public string HostName | |
{ | |
get | |
{ | |
try | |
{ | |
var typedURL = new Uri(URL); | |
return typedURL.Host; | |
} | |
catch (UriFormatException) | |
{ | |
return ""; | |
} | |
} | |
} | |
public event PropertyChangedEventHandler PropertyChanged; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment