我有以下界面:
public delegate void NotifyOnModulesAvailabilityHandler(Lazy [] modules);
public interface IModulesLoader
{
event NotifyOnModulesAvailabilityHandler NotifyOnModulesAvailability;
Lazy<UserControl, IModuleMetadata>[] Modules { get; set; }
void OnImportsSatisfied();
}
我想要实现这样的界面:
public class ModulesLoader : IModulesLoader, IPartImportsSatisfiedNotification
{
#region Events
public event NotifyOnModulesAvailabilityHandler NotifyOnModulesAvailability;
#endregion
#region Public Contructor
public ModulesLoader()
{
DeploymentCatalogService.Instance.Initialize();
CompositionInitializer.SatisfyImports(this);
this.LoadModules();
}
#endregion
#region Properties
[ImportMany(AllowRecomposition = true)]
public Lazy<UserControl, IModuleMetadata>[] Modules
{
get;
set;
}
#endregion
#region IPartImportsSatisfiedNotification Members
public void OnImportsSatisfied()
{
var handler = this.NotifyOnModulesAvailability;
if (handler != null)
{
handler(this.Modules);
}
}
#endregion
#region Private Methods
private void LoadModules()
{
var wc = new WebClient();
wc.OpenReadCompleted += (s, e) =>
{
var streamInfo = e.Result;
var xElement = XElement.Load(streamInfo);
var modulesList = from m in xElement.Elements("ModuleInfo")
select m;
if (modulesList.Any())
{
foreach (var module in modulesList)
{
var moduleName = module.Attribute("XapFilename").Value;
DeploymentCatalogService.Instance.AddXap(moduleName);
}
}
};
wc.OpenReadAsync(new Uri("ModulesCatalog.xml", UriKind.Relative));
}
#endregion
}
我收到以下错误:
错误1'TunisiaMeeting.Extensibility.Shell.Helpers.Deployment.ModulesLoader'未实现接口成员'TunisiaMeeting.MefBase.Interfaces.IModulesLoader.Modules'。 'TunisiaMeeting.Extensibility.Shell.Helpers.Deployment.ModulesLoader.Modules'无法实现'TunisiaMeeting.MefBase.Interfaces.IModulesLoader.Modules',因为它没有匹配的返回类型
'System.Lazy``2<System.Windows.Controls.UserControl,TunisiaMeeting.MefBase.Interfaces.IModuleMetadata>[]'
。 C:\ Imed \ TunisiaMeeting \ TunisiaMeeting.Extensibility.Shell \ Helpers \ Deployment \ ModulesLoader.cs 18 18 TunisiaMeeting.Extensibility.Shell
我很确定我的类和我的属性界面都有相同的返回类型Lazy<UserControl, IModuleMetadata>[]
。
请帮忙吗?
谢谢大家
答案 0 :(得分:1)
您尚未显示UserControl
和IModuleMetadata
来自哪里...我的猜测是您的界面指的是一对类型,而您的实现指的是另一对: