mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-12-15 14:49:42 +00:00
Recherche sans accents
This commit is contained in:
parent
a6a1c53e9b
commit
4ce01fad05
2 changed files with 15 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Text;
|
||||
|
|
@ -17,5 +19,16 @@ namespace AideDeJeu.Tools
|
|||
return serializer.ReadObject(stream) as T;
|
||||
}
|
||||
}
|
||||
|
||||
public static string RemoveDiacritics(string text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return text;
|
||||
|
||||
text = text.Normalize(NormalizationForm.FormD);
|
||||
var chars = text.Where(c => CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark).ToArray();
|
||||
return new string(chars).Normalize(NormalizationForm.FormC);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ namespace AideDeJeu.ViewModels
|
|||
spell.Source.Contains(source) &&
|
||||
spell.Source.Contains(classe) &&
|
||||
spell.Type.Contains(rituel) &&
|
||||
spell.NamePHB.ToLower().Contains(SearchText.ToLower());
|
||||
Helpers.RemoveDiacritics(spell.NamePHB).ToLower().Contains(Helpers.RemoveDiacritics(SearchText).ToLower());
|
||||
})
|
||||
.OrderBy(spell => spell.NamePHB)
|
||||
.ToList();
|
||||
|
|
@ -363,7 +363,7 @@ namespace AideDeJeu.ViewModels
|
|||
monster.Source.Contains(source) &&
|
||||
powerComparer.Compare(monster.Challenge, minPower) >= 0 &&
|
||||
powerComparer.Compare(monster.Challenge, maxPower) <= 0 &&
|
||||
monster.NamePHB.ToLower().Contains(SearchText.ToLower());
|
||||
Helpers.RemoveDiacritics(monster.NamePHB).ToLower().Contains(Helpers.RemoveDiacritics(SearchText).ToLower());
|
||||
})
|
||||
.OrderBy(monster => monster.NamePHB)
|
||||
.ToList();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue