Skip to content

Commit

Permalink
replace ToLower with ToLowerInvariant
Browse files Browse the repository at this point in the history
fixes searching issues on some system locales
  • Loading branch information
nqrcqn committed Sep 5, 2019
1 parent 3cc6fe0 commit 8270b43
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion POEApi.Infrastructure/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static string GetHash(this string input)
StringBuilder sb = new StringBuilder();

foreach (var item in MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(input)))
sb.Append(item.ToString("x2").ToLower());
sb.Append(item.ToString("x2").ToLowerInvariant());

return sb.ToString();
}
Expand Down
4 changes: 2 additions & 2 deletions POEApi.Model/ItemFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static Item Get(JSONProxy.Item item)
if (item.FrameType == 4)
return new Gem(item);

if (item.DescrText != null && item.DescrText.ToLower() == "right click this item then left click a location on the ground to create the object.")
if (item.DescrText != null && item.DescrText.ToLowerInvariant() == "right click this item then left click a location on the ground to create the object.")
return new Decoration(item);

if (item.DescrText != null && string.Equals(item.DescrText,
Expand Down Expand Up @@ -86,7 +86,7 @@ public static Item Get(JSONProxy.Item item)

private static Item GetCurrency(JSONProxy.Item item)
{
var typeline = item.TypeLine.ToLower();
var typeline = item.TypeLine.ToLowerInvariant();

if (typeline.Contains("essence") || typeline.Contains("remnant of"))
return new Essence(item);
Expand Down
2 changes: 1 addition & 1 deletion POEApi.Transport/HttpTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ private string ValidateAndGetHash(string url, string threadTitle, string hashReg

var title = Regex.Match(html, TitleRegex).Groups["Title"].Value;

if (!title.ToLower().Contains(threadTitle.ToLower()))
if (!title.ToLowerInvariant().Contains(threadTitle.ToLowerInvariant()))
throw new ForumThreadException();

return Regex.Match(html, hashRegex).Groups["hash"].Value;
Expand Down
2 changes: 1 addition & 1 deletion Procurement/Controls/Inventory.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private bool search(Item item)
if (string.IsNullOrEmpty(Filter))
return false;

return item.TypeLine.ToLower().Contains(Filter.ToLower()) || item.Name.ToLower().Contains(Filter.ToLower());
return item.TypeLine.ToLowerInvariant().Contains(Filter.ToLowerInvariant()) || item.Name.ToLowerInvariant().Contains(Filter.ToLowerInvariant());
}
}
}
2 changes: 1 addition & 1 deletion Procurement/View/StashView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void AdvancedSearchFilter_KeyUp(object sender, System.Windows.Input.KeyE

foreach (AdvancedSearchCategory category in AdvancedSearchItemControl.ItemsSource)
{
if (category.Key.ToLower().Contains(cb.Text.ToLower()))
if (category.Key.ToLowerInvariant().Contains(cb.Text.ToLowerInvariant()))
{
category.IsVisible = true;
}
Expand Down
4 changes: 2 additions & 2 deletions Procurement/ViewModel/Filters/ForumExport/BuyoutFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public bool Applicable(Item item)
{
var itemInfo = Settings.Buyouts[item.Id];

isItemBuyout = itemInfo.Buyout.ToLower() == buyoutValue.ToLower();
isItemPriced = itemInfo.Price.ToLower() == buyoutValue.ToLower();
isItemBuyout = itemInfo.Buyout.ToLowerInvariant() == buyoutValue.ToLowerInvariant();
isItemPriced = itemInfo.Price.ToLowerInvariant() == buyoutValue.ToLowerInvariant();
}

isTabBuyout = Settings.TabsBuyouts.ContainsKey(ApplicationState.Stash[ApplicationState.CurrentLeague].GetTabNameByInventoryId(item.InventoryId));
Expand Down
2 changes: 1 addition & 1 deletion Procurement/ViewModel/Filters/ForumExport/EssenceFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public FilterGroup Group

public bool Applicable(Item item)
{
var loweredTypeLine = item.TypeLine.ToLower();
var loweredTypeLine = item.TypeLine.ToLowerInvariant();
return loweredTypeLine.Contains("essence") || loweredTypeLine.Contains("remnant of");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public bool Applicable(POEApi.Model.Item item)

try
{
return gem.Properties[0].Name.ToLower().Contains(filter.ToLower());
return gem.Properties[0].Name.ToLowerInvariant().Contains(filter.ToLowerInvariant());
}
catch (Exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class LeagestoneFilter : IFilter

public bool Applicable(Item item)
{
return item.TypeLine.ToLower().Contains("leaguestone");
return item.TypeLine.ToLowerInvariant().Contains("leaguestone");
}
}
}
6 changes: 3 additions & 3 deletions Procurement/ViewModel/Filters/UserSearchFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public bool Applicable(Item item)
if (string.IsNullOrEmpty(filter))
return false;

if (item.TypeLine.ToLower().Contains(filter.ToLower()) || item.Name.ToLower().Contains(filter.ToLower()) || containsMatchedCosmeticMod(item) || isMatchedGear(item))
if (item.TypeLine.ToLowerInvariant().Contains(filter.ToLowerInvariant()) || item.Name.ToLowerInvariant().Contains(filter.ToLowerInvariant()) || containsMatchedCosmeticMod(item) || isMatchedGear(item))
return true;

var gear = item as Gear;
Expand All @@ -48,7 +48,7 @@ public bool Applicable(Item item)

private bool containsMatchedCosmeticMod(Item item)
{
return item.Microtransactions.Any(x => x.ToLower().Contains(filter.ToLower()));
return item.Microtransactions.Any(x => x.ToLowerInvariant().Contains(filter.ToLowerInvariant()));
}

private bool isMatchedGear(Item item)
Expand All @@ -58,7 +58,7 @@ private bool isMatchedGear(Item item)
if (gear == null)
return false;

return gear.GearType.ToString().ToLower().Contains(filter.ToLower());
return gear.GearType.ToString().ToLowerInvariant().Contains(filter.ToLowerInvariant());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class SingleBuyoutVisitor : VisitorBase
public SingleBuyoutVisitor()
{
tokens = Settings.Buyouts.Keys.GroupBy(k => Settings.Buyouts[k].Buyout)
.ToDictionary(g => string.Concat("{", g.Key.ToLower(), "}"), g => (IFilter)new BuyoutFilter(g.Key.ToLower()));
.ToDictionary(g => string.Concat("{", g.Key.ToLowerInvariant(), "}"), g => (IFilter)new BuyoutFilter(g.Key.ToLowerInvariant()));
}
public override string Visit(IEnumerable<POEApi.Model.Item> items, string current)
{
Expand Down
6 changes: 3 additions & 3 deletions Procurement/ViewModel/ForumExportVisitors/VisitorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ internal abstract class VisitorBase : IVisitor
{
protected virtual bool buyoutItemsOnlyVisibleInBuyoutsTag
{
get { return Settings.UserSettings.GetEntry("BuyoutItemsOnlyVisibleInBuyoutsTag").ToLower() == "true"; }
get { return Settings.UserSettings.GetEntry("BuyoutItemsOnlyVisibleInBuyoutsTag").ToLowerInvariant() == "true"; }
}

protected virtual bool embedBuyouts
{
get { return Settings.UserSettings.GetEntry("EmbedBuyouts").ToLower() == "true"; }
get { return Settings.UserSettings.GetEntry("EmbedBuyouts").ToLowerInvariant() == "true"; }
}

protected virtual bool onlyDisplayBuyouts
{
get { return Settings.UserSettings.GetEntry("OnlyDisplayBuyouts").ToLower() == "true"; }
get { return Settings.UserSettings.GetEntry("OnlyDisplayBuyouts").ToLowerInvariant() == "true"; }
}

public abstract string Visit(IEnumerable<Item> items, string current);
Expand Down
2 changes: 1 addition & 1 deletion Procurement/ViewModel/TabViewModel/StashViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public StashViewModel(StashView stashView)

configuredOrbType = OrbType.Chaos;
string currencyDistributionMetric = Settings.UserSettings["CurrencyDistributionMetric"];
if (currencyDistributionMetric.ToLower() == "count")
if (currencyDistributionMetric.ToLowerInvariant() == "count")
currencyDistributionUsesCount = true;
else
configuredOrbType = (OrbType)Enum.Parse(typeof(OrbType), currencyDistributionMetric);
Expand Down

0 comments on commit 8270b43

Please sign in to comment.