MEF:Lazy的反面是什么?类型?
我有一个通过 ImportMany 属性导入的用户控件列表。请参阅以下代码段:
[ImportMany]
private List<Lazy<IUserControl, ILinkerMetadata>> UserControlsMetaData { get; set; }
因此,如果我将每个惰性数据记录添加到例如组合框,则不会加载数据记录,因为它被标记为惰性(结果!:-))
现在,我的问题 - 惰性的反面是什么?。我无法将元数据导入到这样的字典中:
[ImportMany]
private Dictionary<IUserControl, ILinkerMetadata> UserControlsMetaData {get; set;}
提前致谢,
帕特里克
I've a list of usercontrols which I've had imported via ImportMany Attribute. See the following code segment :
[ImportMany]
private List<Lazy<IUserControl, ILinkerMetadata>> UserControlsMetaData { get; set; }
So if I add each Lazy data record to a e.g. combobox, the data record won't be load, because it's tagged as Lazy (consequential! :-))
Now, my question - whats the opposite of Lazy?. I couldn't import the metadata to a dictionary like this :
[ImportMany]
private Dictionary<IUserControl, ILinkerMetadata> UserControlsMetaData {get; set;}
Thanks in advance,
patrick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你想获取元数据,你必须导入到 Lazy 中。当您访问 Value 属性时,将创建控件,因此您可能需要将值添加到 ComboBox。
You have to import into a Lazy if you want to get the metadata. When you access the Value property the control will be created, so you may want to add the Values to your ComboBox.
你可以尝试ExportFactory。在某种程度上,它或多或少与懒惰相反:)
ExportFactory 不是为 wpf 内置的,因此您必须在 mef.codeplex.com 上查看示例项目。
you can try ExportFactory. its more or less the opposite from lazy in some way :)
ExportFactory is not built in for wpf so you have to look on mef.codeplex.com there is the sample project.