开发者

Plugin that can read and modifying host application objects (MEF)

开发者 https://www.devze.com 2023-03-13 05:54 出处:网络
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 modifi

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消