I have created a custom Metadata Attribute for ImportMany in MEF, but ImportMany is always null.
[MetadataAttribute]
[AttributeUsage(AttributeTargets.Class ,AllowMultiple = false)]
public class ModuleAttribute : ExportAttribute ,IModuleMetadata
{
public ModuleAttribute(string contract)
: base(typeof(IScreen))
{
Name = contract;
Region = Region.Sidebar;
IsVisible = true;
}
public string Name { get; set; }
public string Module { get; set; }
public Region Region { get; set; }
public string DisplayName { get; set; }
public bool IsVisible { get; set; }
public string Description { get; set; }
public short Order { get; set; }
public Permissions Permissions { get; set; }
}
And here is how I export my class.
[Module("Stock" ,Module = "Stock" ,Order = 1 ,Permissions = Permissions.View)]
internal sealed class StockWorkSpaceViewModel : Screen
where Screen is typeof(IScreen)
Here is my ImportMany.
[ImportMany]
public IEnumerable<Lazy<IScreen ,IModuleMetadata>> Modules { get; set; }
Can anyone predict, where I am going wrong.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.