Bonjour à tous !

Voici mon problème. J'ai plusieurs listes comprenant des caractères prohibés? J'aimerai filtrer la valeur d'une textbox selon mes cratères prohibés. Et selon le caractère, automatiquement le remplacé.

Tout cela en architecture MVC. Je ne sais pas trop comment faire. Voici mon existant :

MODEL :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
 
namespace ShellAgent.Model.Constant
{
    class OriginFilter
    {
        /// <summary>
        /// List of prohibvalues of A
        /// </summary>
        /// <returns>List string explicit  </returns>
        public List<string> ReplaceA()
        {
            List<string> maList = new List<string>();
            maList.Add("á");
            maList.Add("â");
            maList.Add("à");
            maList.Add("ä");
            maList.Add("ã");
            maList.Add("å");
            maList.Add("Á");
            maList.Add("Â");
            maList.Add("À");
            maList.Add("Ä");
            maList.Add("Ã");
            maList.Add("Å");
 
            return maList;
        }
 
        /// <summary>
        /// List of prohibvalues of E
        /// </summary>
        /// <returns>List string explicit  </returns>
        public List<string> ReplaceE()
        {
            List<string> maList = new List<string>();
            maList.Add("é");
            maList.Add("ê");
            maList.Add("ê");
            maList.Add("è");
            maList.Add("ë");
            maList.Add("É");
            maList.Add("Ê");
            maList.Add("È");
            maList.Add("Ë");
 
            return maList;
        }
 
        /// <summary>
        /// List of prohibvalues of I
        /// </summary>
        /// <returns>List string explicit  </returns>
        public List<string> ReplaceI()
        {
            List<string> maList = new List<string>();
            maList.Add("í");
            maList.Add("î");
            maList.Add("ì");
            maList.Add("ï");
            maList.Add("Í");
            maList.Add("Î");
            maList.Add("Ì");
            maList.Add("Ï");
 
            return maList;
        }
 
        /// <summary>
        /// List of prohibvalues of O
        /// </summary>
        /// <returns>List string explicit  </returns>
        public List<string> ReplaceO()
        {
            List<string> maList = new List<string>();
            maList.Add("ó");
            maList.Add("ô");
            maList.Add("ò");
            maList.Add("ö");
            maList.Add("õ");
            maList.Add("Ó");
            maList.Add("Ô");
            maList.Add("Ò");
            maList.Add("Ö");
            maList.Add("Õ");
 
            return maList;
        }
 
        /// <summary>
        /// List of prohibvalues of U
        /// </summary>
        /// <returns>List string explicit  </returns>
        public List<string> ReplaceU()
        {
            List<string> maList = new List<string>();
            maList.Add("ú");
            maList.Add("û");
            maList.Add("ù");
            maList.Add("ü");
            maList.Add("Ú");
            maList.Add("Û");
            maList.Add("Ù");
            maList.Add("Ü");
 
            return maList;
        }
 
        /// <summary>
        /// List of prohibvalues of Y
        /// </summary>
        /// <returns>List string explicit  </returns>
        public List<string> ReplaceY()
        {
            List<string> maList = new List<string>();
            maList.Add("ý");
            maList.Add("ÿ");
            maList.Add("Ý");
            maList.Add("Ÿ");
 
            return maList;
        }    
 
    }
Mon contrôleur où tous se doit se passer , à la fois l'identification ou pas du caractère prohibé et le remplacement :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
namespace ShellAgent.Controller
{
    internal class Filter
    {
        /// Model
        private readonly Model.Constant.OriginFilter _originReplace = new Model.Constant.OriginFilter();
 
        /// <summary>
        /// Take TextBoxID.text -> Check and Replace Prohibited Character 
        /// </summary>
        /// <param name="textValue"></param>
        /// <returns> Return correct TextBoxId.text </returns>
        public string CheckFilter(string textValue)
        {
            if (textValue.Contains( //Ici ajouter toute les listes pour voir si le mots connais un de ce caractères )
            {
                // Si oui, alors tester si le mot a une caractere de la premiere liste (replaca_A par exemple) et remplacer le caractère par "a"
                //                                                puis tester la seconde liste etc
            }
 
 
            return textValue;
 
        }
    }
}
Ma view Pas tellement importante mais dois recevoir le string vérifié par le contrôleur qu'il est nécessité une correction ou non :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
TextBox_Id.Text = _filter.CheckFilter(TextBox_Id.Text);
Je vous remercie !!