can I hydrate this inside the class's static constructor?
public class Connect:IDTExtensibility2, IDTCommandTarget
static Connect()
{
//hydrate static properties?
}
[Import]
public static Action<ProjectLogicChecks> Display { get; set; }
[Export(typeof(Action<ProjectLogicChecks>))]
private static void DisplayResults( CheckProcesses _checkResults)
{
MessageBox.Show(_checkResults.ProjectLogicCheck.AssemblyName + " has problems=" +
_checkResults.ProjectLogicCheck.HasProblems);
}
No, MEF doesn't support static imports.
You can use [ImportingConstructor] and set the static property in the constructor.
private static RandomService Random { get; set; }
[ImportingConstructor]
public ClientViewModel(RandomService random)
{
Random = random;
}
Just don't set it to a static field.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With