c# - MEF not providing object -
update:
this mvc plugin project, using mef controllers , actions @ run time. http://www.fidelitydesign.net/?p=104
i added new project , in class added export of type being composed.
[export(typeof(icontroller)), exportmetadata("name", "clocks")] public class clockscontroller : controller { public xmlactionresult index() { var p = devicelogic.getunassigned; } [import(typeof(devicelogic))] devicelogic devicelogic { get; set; } }
this gets composed in project:
[export] public class importcontrollerfactory : defaultcontrollerfactory { [importmany] private ienumerable<partfactory<icontroller, icontrollermetadata>> controllerfactories; }
application start
[importmany] private ienumerable<importcontrollerfactory> controllerfactories;
controller factories null, until compose parts
container.composeparts(this);
thats working fine, decided try , emulate devicelogic appear in project im having trouble with.
i created emptry interface (iempty) testing , tried this:
[export(typeof(iempty))] public class requestprocessor : iempty { [import(typeof(devicelogic))] devicelogic devicelogic { get; set; } }
and in applciation start added
[importmany] private ienumerable<iempty> testmef;
this filled 1 instance after composition, seems have worked. question have suggestions why devicelogic null in requestprocessor not in clockscontroller.
you need call mef's satisfyimportsonce
method after instantiation :
yourmefcontainter.satisfyimportsonce(datatransfer)
Comments
Post a Comment