Importing types instead of instances

Jan 3, 2009 at 5:38 PM
Hi guys,

Since the metadata chapter is missing from docs, how would one import types instead of instances?
I mean I'd like to see something like:

[Import(typeof(ISomething)]
public IEnumerable<Type> Something { get; set;}

Is it possible right now?
Jan 4, 2009 at 7:04 AM
Edited Jan 4, 2009 at 7:04 AM
If what you are trying to do is export / import Types over Instances, you can do that. To do so you would use a property export as in below.

For example.

public class PartExportsType {
  [Export("Something")]
  public Type SomeType {get;set;}

  [Export("Something")]
  public Type AnotherType {get;set;}
}

[Export]
public class PartImportsSomeType {
  [Import("Something")]
  public IEnumerable< Type> Something {get;set;} 
}

PartExportsType contains two type exports with the contract of "Something".
PartImportsSomeType imports the collection of available "Something" exports.

Hope this helps.
Glenn