I am trying to export a field called Settings from my Main form to a Plugin as shown in the code below. I am using the Main Form function called CreateSettings() to update the private _settings field. But, when I do that, the imported Plugin Settings never changes and is always the original initialized values "defaultname" and "defaultpass". I am not sure what is going on?
Main Form:
public partial class Form1 : Form
{
[Export(typeof(ISettings))]
private Settings _settings = new Settings("defaultname", "defaultpass");
private void CreateSettings(name, password)
{
_settings = new Settings(name, password);
}
}
Plugin Control:
[Export(typeof(IPlugin))]
public partial class MyPlugin : UserControl, IPlugin
{
[Import(typeof(ISettings))]
private Settings _settings;
}
Settings Class:
public class Settings : ISettings
{
public string Name { get; set; }
public string Password { get; set; }
public Settings()
{
}
public Settings(string name, string pass)
{
Name = name;
Password = pass;
}
}