PtiTom

PropertyChanged

Jul 30th, 2014
214
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public event PropertyChangedEventHandler PropertyChanged;
  2.  
  3. protected virtual void OnPropertyChanged(string propertyName)
  4. {
  5.     this.VerifyProperty(propertyName);
  6.  
  7.     PropertyChangedEventHandler handler = this.PropertyChanged;
  8.     if (handler != null)
  9.     {
  10.         handler(this, new PropertyChangedEventArgs(propertyName));
  11.     }
  12. }
  13.  
  14. [Conditional("DEBUG"), DebuggerStepThrough]
  15. private void VerifyProperty(string propertyName)
  16. {
  17.     Type type = this.GetType();
  18.  
  19.     // Look for a public property with the specified name.
  20.     PropertyInfo propInfo = type.GetProperty(propertyName);
  21.  
  22.     // If the property could not be found,
  23.     // alert the developer of the problem.
  24.     Debug.Assert(propInfo != null, string.Format("{0} is not a public property of {1}", propertyName, type.FullName));
  25. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×