When is the import instantiated?

Feb 13, 2009 at 12:29 AM
I didn't find this in the docs:

When is the following resolved?

 class Program
  {
    [Import]
    public IMessageSender MessageSender { get; set; }
  }

 class Program
  {
    [Import]
    public static IMessageSender MessageSender { get; set; }
  }

 class Program
  {
      [Import]
      private IMessageSender _MessageSender

     public IMessageSender MessageSender { get; }
  }
Developer
Feb 13, 2009 at 5:18 PM
For the first and last samples they will bet resolved if and when you Compose or SatisfyImports on an instance of Program. We don't do anything special to automatically find the Program class. 

For the static import sample we will never statisfy that import because they static imports are not supported (that said in today's released bits that would actually get satisified every time you satisfy the imports of an instance of Program but that is a bug and will eventually be eliminated).