Skip to content

Commit

Permalink
replaced incorrect checking obj for null with pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
DamirAinullin authored and phatboyg committed Jan 13, 2020
1 parent 7638586 commit 6a1f2f7
Showing 1 changed file with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ public void Log(LoggingLevel level, LogWriterOutputProvider messageProvider)
/// <param name="exception">The exception.</param>
public void Debug(object obj, Exception exception)
{
var text = obj as string;
if (obj != null)
if (obj is string text)
{
this.logger.LogDebug(0, exception, text);
}
Expand Down Expand Up @@ -184,8 +183,7 @@ public void Debug(LogWriterOutputProvider messageProvider)
/// <param name="exception">The exception.</param>
public void Info(object obj, Exception exception)
{
var text = obj as string;
if (obj != null)
if (obj is string text)
{
this.logger.LogInformation(0, exception, text);
}
Expand Down Expand Up @@ -232,8 +230,7 @@ public void Info(LogWriterOutputProvider messageProvider)
/// <param name="obj">The object.</param>
public void Warn(object obj)
{
var text = obj as string;
if (obj != null)
if (obj is string text)
{
this.logger.LogWarning(text);
}
Expand All @@ -250,8 +247,7 @@ public void Warn(object obj)
/// <param name="exception">The exception.</param>
public void Warn(object obj, Exception exception)
{
var text = obj as string;
if (obj != null)
if (obj is string text)
{
this.logger.LogWarning(0, exception, text);
}
Expand Down Expand Up @@ -298,8 +294,7 @@ public void Warn(LogWriterOutputProvider messageProvider)
/// <param name="obj">The object.</param>
public void Error(object obj)
{
var text = obj as string;
if (obj != null)
if (obj is string text)
{
this.logger.LogError(text);
}
Expand All @@ -316,8 +311,7 @@ public void Error(object obj)
/// <param name="exception">The exception.</param>
public void Error(object obj, Exception exception)
{
var text = obj as string;
if (obj != null)
if (obj is string text)
{
this.logger.LogError(0, exception, text);
}
Expand Down Expand Up @@ -364,8 +358,7 @@ public void Error(LogWriterOutputProvider messageProvider)
/// <param name="obj">The object.</param>
public void Fatal(object obj)
{
var text = obj as string;
if (obj != null)
if (obj is string text)
{
this.logger.LogCritical(text);
}
Expand All @@ -382,8 +375,7 @@ public void Fatal(object obj)
/// <param name="exception">The exception.</param>
public void Fatal(object obj, Exception exception)
{
var text = obj as string;
if (obj != null)
if (obj is string text)
{
this.logger.LogCritical(0, exception, text);
}
Expand Down

0 comments on commit 6a1f2f7

Please sign in to comment.