假设我有以下3个类:
<input type="text" value="This text is auto capitalized" />
例如,如果可以这样做:
[Export("Settings",typeof(ISettingsItem)]
[PartCreationPolicy(CreationPolicy.Shared)]
public class Settings1Vm {}
[Export("Settings",typeof(ISettingsItem)]
[PartCreationPolicy(CreationPolicy.Shared)]
public class Settings2Vm {}
[Export("Settings",typeof(ISettingsItem)]
[PartCreationPolicy(CreationPolicy.Shared)]
public class Settings3Vm {}
但是这种导入只能导出Settings2VM类吗?
问候
答案 0 :(得分:0)
似乎解决方案是:
[Export("Settings",typeof(ISettingsItem)]
[Export("Settings2Vm ",typeof(ISettingsItem)]
[PartCreationPolicy(CreationPolicy.Shared)]
public class Settings2Vm {}
[Import("Settings2Vm ", typeof(ISettingsItemVM))]
private Settings2Vm SettingEntry{ get; set; }
这样我将始终拥有相同的实例。