我正在尝试将 StructureMap 与 OpenRasta 一起使用。我的Configuration
班级实现IDependencyResolverAccessor
. 这是我配置容器的代码:
container.Configure(x =>
{
x.For<IFileResourceRepository>().Use(
r => new FileResourceSqlRepository(ConnectionString));
x.For<ILog>().Use(l => new FileLog(LogFileName, _logLevel));
x.For<ILogger>().Use<ProTeckLogger>();
x.For<ILogger<CodecLogSource>>().Use<ProTeckLogger<CodecLogSource>>();
x.For<ILogger<IOLogSource>>().Use<ProTeckLogger<IOLogSource>>();
x.For<ILogger<OperationModelLogSource>>().Use<ProTeckLogger<OperationModelLogSource>>();
x.For<ILogger<PipelineLogSource>>().Use<ProTeckLogger<PipelineLogSource>>();
x.SetAllProperties(
policy =>
policy.Matching(
prop => (prop.PropertyType.IsAssignableFrom(typeof (ILogger)))));
x.SetAllProperties(policy => policy.OfType<IFileResourceRepository>());
x.SetAllProperties(policy => policy.OfType<ILog>());
x.SetAllProperties(policy => policy.OfType<ILogger<CodecLogSource>>());
x.SetAllProperties(policy => policy.OfType<ILogger<IOLogSource>>());
x.SetAllProperties(policy => policy.OfType<ILogger<OperationModelLogSource>>());
x.SetAllProperties(policy => policy.OfType<ILogger<PipelineLogSource>>());
});
我收到以下错误:
StructureMap Exception Code: 202
No Default Instance defined for PluginFamily System.Diagnostics.TraceSource, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
我想也许我错过了注册?我可能做错了什么吗?
谢谢-