Programmer Question
If I have a class that contains some properties and methods, and when a property is changed, it fires an event (in this case passing a string in the args):
public class Settings
{
public delegate void SettingsChangedHandler(object sender, string e);
public event SettingsChangedHandler SettingsChanged;
private string rootfolder;
public string RootFolder
{
get { return rootfolder; }
set
{
rootfolder = value;
if (SettingsChanged != null)
SettingsChanged(this, "ROOT_FOLDER");
}
}
}
If i have somewhere in my code:
public Settings SettingsInstance = new Settings();
SettingsInstance.SettingsChanged += new SettingsChangedHandler(SettingsInstance_SettingsChanged);
SettingsInstance = SomeOtherSettingsInstance;
I want all of the properties that have changed to fire their events.
How do I achieve something like this? Surely I don't have to copy them over one at a time?
No comments:
Post a Comment