c# - MEF share instance between modules -
i'm using prism/mef c# application. want following, i'm new prism , maybe i'm doing wrong or got wrong not work showed below.
i created 2 modules, in module1 created instance of class. want share instance other module2.
something this:
module1 (viewmodel):
[export("me")] private person me = new person(); //within function... me.name = "jasmin";
module2 (viewmodel):
[import("me")] private lazy<person> me; //within function console.writeline(me.name); //here want "jasmin"
shared model class:
public class details { public string name; } public class person { public name first = new name(); }
it works shown in question. had rebuild entire solution.
to access object later on, instead of:
console.writeline(me.name); //here want "jasmin"
one has use:
console.writeline(me.value.name); //here want "jasmin"
thanks help.
Comments
Post a Comment