hi, i'm a beginner in mef and so i have a question :) i have the following:
[PartCreationPolicy(CreationPolicy.Shared)]
[Export(typeof(SharedExport))]
public class SharedExport : INPCBase
{
[ImportMany(typeof(INonShared),RequiredCreationPolicy = CreationPolicy.NonShared)]
private IEnumerable<Lazy<INonShared,Dictionary<string,object>>> fac;
...
public void Open()
{
foreach (var lazy in fac)
{
this.Muster.Add(lazy.Value);
}
}
the imported classes all marked as nonshared.
[PartCreationPolicy(CreationPolicy.NonShared)]
[Export(typeof(INonShared))]
[ExportMetadata("Muster","030")]
public sealed class NonShared1 : INPCBase, INonShared
{
public NonShared1()
{
Debug.WriteLine("ctor NonShared1" + this.GetHashCode().ToString());
}
#region Implementation of INonShared
public string Displayname
{
get { return "Muster 030 "+ this.GetHashCode().ToString();
}
}
#endregion
}
now my question: when Open() execute, shouldn't there always a new NonShared1 instance be created? i got always the same.