Register ILoggerFactory
This commit is contained in:
Родитель
2bd8f20ea5
Коммит
b2cea341dc
|
@ -26,9 +26,8 @@ namespace Unity.Microsoft.Logging
|
|||
|
||||
[InjectionConstructor]
|
||||
public LoggingExtension()
|
||||
{
|
||||
LoggerFactory = new LoggerFactory();
|
||||
}
|
||||
: this(new LoggerFactory())
|
||||
{ }
|
||||
|
||||
public LoggingExtension(ILoggerFactory factory)
|
||||
{
|
||||
|
@ -50,7 +49,8 @@ namespace Unity.Microsoft.Logging
|
|||
|
||||
protected override void Initialize()
|
||||
{
|
||||
Context.Policies.Set(typeof(ILogger), UnityContainer.All, typeof(ResolveDelegateFactory), (ResolveDelegateFactory)GetResolver);
|
||||
Context.Policies.Set(typeof(ILoggerFactory), UnityContainer.All, typeof(ResolveDelegateFactory), (ResolveDelegateFactory)GetFactoryResolver);
|
||||
Context.Policies.Set(typeof(ILogger), UnityContainer.All, typeof(ResolveDelegateFactory), (ResolveDelegateFactory)GetResolver);
|
||||
Context.Policies.Set(typeof(ILogger<>), UnityContainer.All, typeof(ResolveDelegateFactory), (ResolveDelegateFactory)GetResolverGeneric);
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,14 @@ namespace Unity.Microsoft.Logging
|
|||
|
||||
#region IResolveDelegateFactory
|
||||
|
||||
public ResolveDelegate<BuilderContext> GetFactoryResolver(ref BuilderContext context)
|
||||
{
|
||||
return ((ref BuilderContext c) =>
|
||||
{
|
||||
return LoggerFactory;
|
||||
});
|
||||
}
|
||||
|
||||
public ResolveDelegate<BuilderContext> GetResolver(ref BuilderContext context)
|
||||
{
|
||||
return ((ref BuilderContext c) =>
|
||||
|
|
|
@ -33,6 +33,12 @@ namespace Microsoft.Logging.Tests
|
|||
Assert.IsInstanceOfType(factory, typeof(ILoggerFactory));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void microsoft_logging_factory_resolve_LoggerFactory()
|
||||
{
|
||||
Assert.IsNotNull(_container.Resolve<ILoggerFactory>());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void microsoft_logging_factory_CreateLogger_Category()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче