ImportingConstructor with arguments

Jan 13, 2011 at 8:05 PM

Hello everyone,

I have a Problem with MEF and Constructor arguments.

I have a class:

[Export(typeof(IFoo))]
class Foo : IFoo
{
  private readonly int z;

  [ImportingConstructor]
  public Foo(int x, int y)
  {
    z = x + y;
  }

  public int Z
  {
    get { return z; }
  }
}

Now i need MEF to create a couple of instances of this class, using different x and y values.

How do i do this?