initial commit
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Extensions.Logging.Log4Net.AspNetCore.Scope
|
||||
{
|
||||
/// <summary>
|
||||
/// A logger scope that does not save any information and does not need to be disposed.
|
||||
/// </summary>
|
||||
internal class NullScope : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton instance that represent every <see cref="NullScope"/>.
|
||||
/// </summary>
|
||||
internal static NullScope Instance { get; } = new NullScope();
|
||||
|
||||
/// <summary>
|
||||
/// Constructor that prevents external instantiation.
|
||||
/// </summary>
|
||||
private NullScope()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
// This is a null scope so we need to dispose nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Extensions.Logging.Log4Net.AspNetCore.Scope
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="IExternalScopeProvider"/> that will not save nor return scopes.
|
||||
/// </summary>
|
||||
internal class NullScopeProvider : IExternalScopeProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton instance that represents every <see cref="NullScopeProvider"/>.
|
||||
/// </summary>
|
||||
internal static NullScopeProvider Instance { get; } = new NullScopeProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Constructor that prevents external instantiation.
|
||||
/// </summary>
|
||||
private NullScopeProvider()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void ForEachScope<TState>(Action<object, TState> callback, TState state)
|
||||
{
|
||||
// All scopes are null scopes so do nothing.
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IDisposable Push(object state)
|
||||
{
|
||||
return NullScope.Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user