Skip to content

Commit

Permalink
Add basic support for the possibility of making IgnoreSymbols an opti…
Browse files Browse the repository at this point in the history
…onal

item for comparisons.
  • Loading branch information
Kinematics committed Dec 18, 2015
1 parent 648a8dd commit 8d875f6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions TallyCore/Tally.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ public DisplayMode DisplayMode
UpdateResults();
}
}


public bool IgnoreSymbols
{
get { return Utility.Text.IgnoreSymbols; }
set
{
Utility.Text.IgnoreSymbols = value;
OnPropertyChanged();
}
}
#endregion

#region Interface functions
Expand Down
8 changes: 7 additions & 1 deletion TallyCore/Utility/Text.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,15 @@ public static string FirstLine(string input)
/// A string comparer object that allows comparison between strings that
/// can ignore lots of annoying user-entered variances.
/// </summary>
public static IEqualityComparer<string> AgnosticStringComparer { get; } = new CustomStringComparer(CultureInfo.InvariantCulture.CompareInfo,
public static IEqualityComparer<string> AgnosticStringComparer => IgnoreSymbols ? AgnosticStringComparer1 : AgnosticStringComparer2;

public static bool IgnoreSymbols { get; set; } = true;

private static IEqualityComparer<string> AgnosticStringComparer1 { get; } = new CustomStringComparer(CultureInfo.InvariantCulture.CompareInfo,
CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreWidth);

private static IEqualityComparer<string> AgnosticStringComparer2 { get; } = new CustomStringComparer(CultureInfo.InvariantCulture.CompareInfo,
CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreWidth);
}

/// <summary>
Expand Down

0 comments on commit 8d875f6

Please sign in to comment.