Plugin that can read and modifying host application objects (MEF)
How i can create plugin that can read and modifying host application objects with MEF? For example, host application has TextBox object. I need create plugin that can read text from TextBox and modified it.
In this example i'm try access to string:
In host application i'm write follow:
string _str_test;
[Export("str_test")]
public string str_test
{
get { return _str_test; }
set { _str_test = value; }
}
In plugin i'm write follow:
string _str_test;
[Import("str_test")]
public string str_test
开发者_Python百科 {
get { return _str_test; }
set { _str_test = value; }
}
But str_test is null.
You need to create a CompositionContainer
. The container should create the plugins. It should also create the classes in the host application that have imports, if that is possible. If not you can call container.SatisfyImports(hostObject)
to have the imports on an object satisfied.
精彩评论