Created
September 20, 2012 06:53
-
-
Save SimonCropp/3754317 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ApplicationController | |
{ | |
string myProperty; | |
public string MyProperty | |
{ | |
get { return myProperty; } | |
set { | |
myProperty = value; | |
MyPropertyChanged(value); | |
} | |
} | |
public event Action<string> MyPropertyChanged = s => {}; | |
} | |
public class ClassThatConsumes: IDisposable | |
{ | |
ApplicationController applicationController; | |
//ApplicationController injected by IOC | |
public ClassThatConsumes(ApplicationController applicationController) | |
{ | |
this.applicationController = applicationController; | |
applicationController.MyPropertyChanged += HandleMyPropertyChanged; | |
} | |
void HandleMyPropertyChanged(string propertyValue) | |
{ | |
Debug.WriteLine(propertyValue); | |
} | |
public void Dispose() | |
{ | |
applicationController.MyPropertyChanged -= HandleMyPropertyChanged; | |
} | |
} | |
public class ClassThatSets | |
{ | |
ApplicationController applicationController; | |
//ApplicationController injected by IOC | |
public ClassThatSets(ApplicationController applicationController) | |
{ | |
this.applicationController = applicationController; | |
} | |
public void ChangeProperty() | |
{ | |
applicationController.MyProperty = "NewValue"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment