Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
simplified logic
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanJosipovic committed Oct 26, 2019
1 parent 42b8ba9 commit 76ee580
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/BlazorTable/Filters/StringFilter.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,38 +62,44 @@ protected override void OnInitialized()

private StringCondition GetConditionFromMethod(string method, bool not)
{
if (method == nameof(string.IndexOf) && !not)
if (not)
{
return StringCondition.Contains;
if (method == nameof(string.IndexOf))
{
return StringCondition.DoesNotContain;
}
else if (method == nameof(string.Equals))
{
return StringCondition.IsNotEqualTo;
}
else if (method == nameof(string.IsNullOrEmpty))
{
return StringCondition.IsNotNulOrEmpty;
}

throw new InvalidOperationException("Shouldn't be here");
}
else if (method == nameof(string.IndexOf) && not)

if (method == nameof(string.IndexOf))
{
return StringCondition.DoesNotContain;
return StringCondition.Contains;
}
else if (method == nameof(string.StartsWith) && !not)
else if (method == nameof(string.StartsWith))
{
return StringCondition.StartsWith;
}
else if (method == nameof(string.EndsWith) && !not)
else if (method == nameof(string.EndsWith))
{
return StringCondition.EndsWith;
}
else if (method == nameof(string.Equals) && !not)
else if (method == nameof(string.Equals))
{
return StringCondition.IsEqualTo;
}
else if (method == nameof(string.Equals) && not)
{
return StringCondition.IsNotEqualTo;
}
else if (method == nameof(string.IsNullOrEmpty) && !not)
else if (method == nameof(string.IsNullOrEmpty))
{
return StringCondition.IsNullOrEmpty;
}
else if (method == nameof(string.IsNullOrEmpty) && not)
{
return StringCondition.IsNotNulOrEmpty;
}

throw new InvalidOperationException("Shouldn't be here");
}
Expand Down

0 comments on commit 76ee580

Please sign in to comment.