@@ -19,28 +19,15 @@ public enum MagicControlStrategy
1919
2020public static class MagicControlHelper
2121{
22- private static readonly Random Random = new ( ) ;
23-
24-
2522 private static string GetImplicitGroupString ( ShowImplicitGroups showGroups )
2623 {
27- string implicitGroupsString ;
28- switch ( showGroups )
24+ return showGroups switch
2925 {
30- case ShowImplicitGroups . None :
31- implicitGroupsString = "'none'" ;
32- break ;
33- case ShowImplicitGroups . Children :
34- implicitGroupsString = "'children'" ;
35- break ;
36- case ShowImplicitGroups . Parents :
37- implicitGroupsString = "'parents'" ;
38- break ;
39- default :
40- throw new ArgumentOutOfRangeException ( nameof ( showGroups ) , showGroups , null ) ;
41- }
42-
43- return implicitGroupsString ;
26+ ShowImplicitGroups . None => "'none'" ,
27+ ShowImplicitGroups . Children => "'children'" ,
28+ ShowImplicitGroups . Parents => "'parents'" ,
29+ _ => throw new ArgumentOutOfRangeException ( nameof ( showGroups ) , showGroups , null ) ,
30+ } ;
4431 }
4532
4633 public static HtmlString GetMagicSelect ( int projectId , bool showCharacters , ShowImplicitGroups showGroups ,
@@ -70,20 +57,17 @@ public static HtmlString GetMagicSelect(int projectId, bool showCharacters, Show
7057 $('#{0}_control_{6}').multicontrol(options);
7158 }});
7259 </script>" , propertyName , projectId , showCharacters ? "true" : "false" , implicitGroupsString ,
73- strategyString , elements . JoinStrings ( ", " ) , Random . Next ( ) , showSpecial ? "json_full" : "json_real" ) ) ;
60+ strategyString , elements . JoinStrings ( ", " ) , Random . Shared . Next ( ) , showSpecial ? "json_full" : "json_real" ) ) ;
7461 return magicSelectFor ;
7562 }
7663
7764 private static string GetStrategyString ( MagicControlStrategy strategy )
7865 {
79- switch ( strategy )
66+ return strategy switch
8067 {
81- case MagicControlStrategy . Changer :
82- return "changer" ;
83- case MagicControlStrategy . NonChanger :
84- return "nonchanger" ;
85- default :
86- throw new ArgumentOutOfRangeException ( nameof ( strategy ) , strategy , null ) ;
87- }
68+ MagicControlStrategy . Changer => "changer" ,
69+ MagicControlStrategy . NonChanger => "nonchanger" ,
70+ _ => throw new ArgumentOutOfRangeException ( nameof ( strategy ) , strategy , null ) ,
71+ } ;
8872 }
8973}
0 commit comments