Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
fixing #26: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sonjakhan committed Oct 2, 2014
1 parent a1d27a1 commit ec769fd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ public interface ILoggerFactory

void AddProvider(ILoggerProvider provider);
}
}
}
8 changes: 4 additions & 4 deletions src/Microsoft.Framework.Logging/DiagnosticsScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.Framework.Logging
public class DiagnosticsScope : IDisposable
{
// To detect redundant calls
private bool _disposedValue;
private bool _isDisposed;

/// <summary>
/// Pushes state onto the LogicalOperationStack by calling
Expand All @@ -34,14 +34,14 @@ public DiagnosticsScope(object state)
/// <param name="state">The state.</param>
public void Dispose()
{
if (!_disposedValue)
if (!_isDisposed)
{
#if NET45 || ASPNET50
Trace.CorrelationManager.StopLogicalOperation();
#endif
_disposedValue = true;
_isDisposed = true;
}
}
}
}
#endif
#endif
18 changes: 9 additions & 9 deletions src/Microsoft.Framework.Logging/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace Microsoft.Framework.Logging
{
internal class Logger : ILogger
{
private LoggerFactory _loggerFactory;
private string _name;
private readonly LoggerFactory _loggerFactory;
private readonly string _name;
private ILogger[] _loggers = new ILogger[0];

public Logger(LoggerFactory loggerFactory, string name)
Expand All @@ -19,7 +19,7 @@ public Logger(LoggerFactory loggerFactory, string name)

var providers = loggerFactory.GetProviders();
_loggers = new ILogger[providers.Length];
for (var index = 0; index != providers.Length; ++index)
for (var index = 0; index != providers.Length; index++)
{
_loggers[index] = providers[index].Create(name);
}
Expand All @@ -29,7 +29,7 @@ public bool WriteCore(TraceType eventType, int eventId, object state, Exception
{
var result = false;
var count = _loggers.Length;
for (var index = 0; index != count; ++index)
for (var index = 0; index != count; index++)
{
result |= _loggers[index].WriteCore(eventType, eventId, state, exception, formatter);
}
Expand All @@ -40,7 +40,7 @@ public IDisposable BeginScope(object state)
{
var count = _loggers.Length;
var scope = new Scope(count);
for (var index = 0; index != count; ++index)
for (var index = 0; index != count; index++)
{
scope.SetDisposable(index, _loggers[index].BeginScope(state));
}
Expand All @@ -55,7 +55,7 @@ internal void AddProvider(ILoggerProvider provider)

private class Scope : IDisposable
{
private bool disposedValue = false;
private bool _isDisposed;

private IDisposable _disposable0;
private IDisposable _disposable1;
Expand Down Expand Up @@ -87,7 +87,7 @@ public void SetDisposable(int index, IDisposable disposable)

protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
if (!_isDisposed)
{
if (disposing)
{
Expand All @@ -112,7 +112,7 @@ protected virtual void Dispose(bool disposing)
}
}

disposedValue = true;
_isDisposed = true;
}
}

Expand All @@ -131,4 +131,4 @@ internal void Add(IDisposable disposable)
}
}
}
}
}
8 changes: 3 additions & 5 deletions src/Microsoft.Framework.Logging/LoggerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ namespace Microsoft.Framework.Logging
/// </summary>
public class LoggerFactory : ILoggerFactory
{
Dictionary<string, Logger> _loggers = new Dictionary<string, Logger>(StringComparer.Ordinal);
ILoggerProvider[] _providers = new ILoggerProvider[0];
object _sync = new object();
private readonly Dictionary<string, Logger> _loggers = new Dictionary<string, Logger>(StringComparer.Ordinal);
private ILoggerProvider[] _providers = new ILoggerProvider[0];
private readonly object _sync = new object();

public ILogger Create(string name)
{
Expand Down Expand Up @@ -47,6 +47,4 @@ internal ILoggerProvider[] GetProviders()
return _providers;
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.Framework.Logging.Test
{
public class DiagnosticsScopeTests
public class DiagnosticsScopeTest
{
#if ASPNET50
[Fact]
Expand Down

0 comments on commit ec769fd

Please sign in to comment.