Skip to content

Instantly share code, notes, and snippets.

@SimonCropp
Created September 20, 2012 06:53
Show Gist options
  • Save SimonCropp/3754317 to your computer and use it in GitHub Desktop.
Save SimonCropp/3754317 to your computer and use it in GitHub Desktop.
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