This commit is contained in:
Oskar Klintrot 2019-03-13 15:23:48 +01:00
Родитель 2bd8f20ea5
Коммит b2cea341dc
2 изменённых файлов: 18 добавлений и 4 удалений

Просмотреть файл

@ -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()
{