Skip to content

Commit

Permalink
Invert if statement to reduce nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
senioroman4uk committed Mar 5, 2024
1 parent aa48739 commit 62d052b
Showing 1 changed file with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,25 +298,22 @@ internal bool IsDeltaOfT
{
get
{
if (_isDeltaOfT == null)
if (_isDeltaOfT is not null)
{
if (Type == null)
{
_isDeltaOfT = false;
}
else if (Type.IsGenericType)
{
var genericTypeDefinition = Type.GetGenericTypeDefinition();
_isDeltaOfT = (genericTypeDefinition == typeof(Delta<>) ||
genericTypeDefinition == typeof(DeltaSet<>) ||
genericTypeDefinition == typeof(DeltaDeletedResource<>));
}
else
{
_isDeltaOfT = false;
}
return _isDeltaOfT.Value;
}

if (Type is not { IsGenericType: true })
{
_isDeltaOfT = false;
return _isDeltaOfT.Value;
}

var genericTypeDefinition = Type.GetGenericTypeDefinition();
_isDeltaOfT = genericTypeDefinition == typeof(Delta<>) ||
genericTypeDefinition == typeof(DeltaSet<>) ||
genericTypeDefinition == typeof(DeltaDeletedResource<>);

return _isDeltaOfT.Value;
}
}
Expand Down

0 comments on commit 62d052b

Please sign in to comment.