Skip to content

Commit 23fb0e2

Browse files
committed
code style cleanup
1 parent 0a2b7c4 commit 23fb0e2

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

Text-Grab/Utilities/CustomBottomBarUtilities.cs

+5-14
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static List<ButtonInfo> GetCustomBottomBarItemsSetting()
2020
if (string.IsNullOrWhiteSpace(json))
2121
return ButtonInfo.DefaultButtonList;
2222

23-
List<ButtonInfo>? customBottomBarItems = new();
23+
List<ButtonInfo>? customBottomBarItems = [];
2424

2525
customBottomBarItems = JsonSerializer.Deserialize<List<ButtonInfo>>(json);
2626

@@ -41,10 +41,9 @@ public static List<ButtonInfo> GetCustomBottomBarItemsSetting()
4141
return customBottomBarItems;
4242
}
4343

44-
// a method to save a list of collapsible buttons to the settings as json
4544
public static void SaveCustomBottomBarItemsSetting(List<CollapsibleButton> bottomBarButtons)
4645
{
47-
List<ButtonInfo> customButtons = new();
46+
List<ButtonInfo> customButtons = [];
4847

4948
foreach (CollapsibleButton collapsible in bottomBarButtons)
5049
customButtons.Add(new(collapsible));
@@ -54,20 +53,15 @@ public static void SaveCustomBottomBarItemsSetting(List<CollapsibleButton> botto
5453

5554
public static void SaveCustomBottomBarItemsSetting(List<ButtonInfo> bottomBarButtons)
5655
{
57-
// serialize the list of custom bottom bar items to json
5856
string json = JsonSerializer.Serialize(bottomBarButtons);
59-
60-
// save the json string to the settings
6157
AppUtilities.TextGrabSettings.BottomButtonsJson = json;
62-
63-
// save the settings
6458
AppUtilities.TextGrabSettings.Save();
6559
}
6660

6761
public static List<CollapsibleButton> GetBottomBarButtons(EditTextWindow editTextWindow)
6862
{
69-
List<CollapsibleButton> bottomBarButtons = new();
70-
Dictionary<string, RoutedCommand> _localRoutedCommands = new();
63+
List<CollapsibleButton> bottomBarButtons = [];
64+
Dictionary<string, RoutedCommand> _localRoutedCommands = [];
7165
List<MethodInfo> methods = GetMethods(editTextWindow);
7266
Dictionary<string, RoutedCommand> routedCommands = EditTextWindow.GetRoutedCommands();
7367

@@ -105,13 +99,11 @@ public static List<CollapsibleButton> GetBottomBarButtons(EditTextWindow editTex
10599
return bottomBarButtons;
106100
}
107101

108-
// a method which returns a list of all methods in this class
109102
private static List<MethodInfo> GetMethods(object obj)
110103
{
111-
return obj.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).ToList();
104+
return [.. obj.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)];
112105
}
113106

114-
// using the above method match a method name to a string parameter
115107
private static MethodInfo? GetMethodInfoForName(string methodName, List<MethodInfo> methods)
116108
{
117109
foreach (MethodInfo method in methods)
@@ -121,7 +113,6 @@ private static List<MethodInfo> GetMethods(object obj)
121113
return null;
122114
}
123115

124-
// a method to match a command name to a string parameter
125116
private static RoutedCommand? GetCommandBinding(string commandName, Dictionary<string, RoutedCommand> routedCommands)
126117
{
127118
foreach (string commandKey in routedCommands.Keys)

0 commit comments

Comments
 (0)