Skip to content

Commit 2282b3b

Browse files
committed
🎨 formatting
semver: chore
1 parent d70186e commit 2282b3b

14 files changed

Lines changed: 173 additions & 189 deletions

EliteAPI/Class1.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

EliteAPI/JsonExtensions.cs

Lines changed: 108 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -6,131 +6,122 @@ namespace EliteAPI;
66

77
public static class JExtensions
88
{
9-
public static IEnumerable<JValue> GetLeafValues(this JToken jToken)
10-
{
11-
if (jToken is JValue jvalue)
12-
{
13-
yield return jvalue;
14-
}
15-
else if (jToken is JArray jArray)
16-
{
17-
foreach (var result in GetLeafValuesFromJArray(jArray))
18-
{
19-
yield return result;
20-
}
9+
public static IEnumerable<JValue> GetLeafValues(this JToken jToken)
10+
{
11+
if (jToken is JValue jvalue)
12+
{
13+
yield return jvalue;
14+
}
15+
else if (jToken is JArray jArray)
16+
{
17+
foreach (var result in GetLeafValuesFromJArray(jArray))
18+
{
19+
yield return result;
20+
}
2121

22-
// yield return GetLeafValues(JToken.Parse($"{{ {jArray.Path.Replace(".", "")}: {{ 'Length': {jArray.Count} }} }}")).First();
23-
yield return GetLeafValuesFromJProperty(new JProperty($"{jArray.Path}.Length", jArray.Count)).First();
22+
// yield return GetLeafValues(JToken.Parse($"{{ {jArray.Path.Replace(".", "")}: {{ 'Length': {jArray.Count} }} }}")).First();
23+
yield return GetLeafValuesFromJProperty(new JProperty($"{jArray.Path}.Length", jArray.Count)).First();
2424

25-
}
26-
else if (jToken is JProperty jProperty)
27-
{
28-
foreach (var result in GetLeafValuesFromJProperty(jProperty))
29-
{
30-
yield return result;
31-
}
32-
}
33-
else if (jToken is JObject jObject)
34-
{
35-
foreach (var result in GetLeafValuesFromJObject(jObject))
36-
{
37-
yield return result;
38-
}
39-
}
40-
}
25+
}
26+
else if (jToken is JProperty jProperty)
27+
{
28+
foreach (var result in GetLeafValuesFromJProperty(jProperty))
29+
{
30+
yield return result;
31+
}
32+
}
33+
else if (jToken is JObject jObject)
34+
{
35+
foreach (var result in GetLeafValuesFromJObject(jObject))
36+
{
37+
yield return result;
38+
}
39+
}
40+
}
4141

4242

43-
// JSONToken -> JsonPath
44-
public static JsonPath ToCustomJsonPath(this JValue jValue)
45-
{
46-
switch (jValue.Type)
47-
{
48-
case JTokenType.Integer:
49-
return new JsonPath
50-
{
51-
Path = NormalizePath(jValue.Path),
52-
Value = Convert.ToInt32(jValue.Value),
53-
Type = JsonType.Number
54-
};
55-
case JTokenType.Float:
56-
return new JsonPath
57-
{
58-
Path = NormalizePath(jValue.Path),
59-
Value = Convert.ToDecimal(jValue.Value),
60-
Type = JsonType.Decimal
61-
};
43+
// JSONToken -> JsonPath
44+
public static JsonPath ToCustomJsonPath(this JValue jValue)
45+
{
46+
return jValue.Type switch
47+
{
48+
JTokenType.Integer => new JsonPath
49+
{
50+
Path = NormalizePath(jValue.Path),
51+
Value = Convert.ToInt32(jValue.Value),
52+
Type = JsonType.Number
53+
},
54+
JTokenType.Float => new JsonPath
55+
{
56+
Path = NormalizePath(jValue.Path),
57+
Value = Convert.ToDecimal(jValue.Value),
58+
Type = JsonType.Decimal
59+
},
60+
JTokenType.Uri or JTokenType.Guid or JTokenType.String => new JsonPath
61+
{
62+
Path = NormalizePath(jValue.Path),
63+
Value = Convert.ToString(jValue.Value),
64+
Type = JsonType.String
65+
},
66+
JTokenType.Boolean => new JsonPath
67+
{
68+
Path = NormalizePath(jValue.Path),
69+
Value = Convert.ToBoolean(jValue.Value),
70+
Type = JsonType.Boolean
71+
},
72+
JTokenType.Date => new JsonPath
73+
{
74+
Path = NormalizePath(jValue.Path),
75+
Value = Convert.ToDateTime(jValue.Value),
76+
Type = JsonType.DateTime
77+
},
78+
_ => new JsonPath
79+
{
80+
Path = "",
81+
Value = "",
82+
Type = JsonType.String
83+
},
84+
};
85+
}
6286

63-
case JTokenType.Uri:
64-
case JTokenType.Guid:
65-
case JTokenType.String:
66-
return new JsonPath
67-
{
68-
Path = NormalizePath(jValue.Path),
69-
Value = Convert.ToString(jValue.Value),
70-
Type = JsonType.String
71-
};
72-
case JTokenType.Boolean:
73-
return new JsonPath
74-
{
75-
Path = NormalizePath(jValue.Path),
76-
Value = Convert.ToBoolean(jValue.Value),
77-
Type = JsonType.Boolean
78-
};
79-
case JTokenType.Date:
80-
return new JsonPath
81-
{
82-
Path = NormalizePath(jValue.Path),
83-
Value = Convert.ToDateTime(jValue.Value),
84-
Type = JsonType.DateTime
85-
};
86-
default:
87-
return new JsonPath
88-
{
89-
Path = "",
90-
Value = "",
91-
Type = JsonType.String
92-
};
93-
}
94-
}
87+
#region Helpers
9588

96-
#region Helpers
89+
static string NormalizePath(string rawPath)
90+
{
91+
if (rawPath.StartsWith("['") && rawPath.EndsWith("']"))
92+
return rawPath.Substring(2, rawPath.Length - 4);
93+
return rawPath;
94+
}
9795

98-
static string NormalizePath(string rawPath)
99-
{
100-
if (rawPath.StartsWith("['") && rawPath.EndsWith("']"))
101-
return rawPath.Substring(2, rawPath.Length - 4);
102-
return rawPath;
103-
}
96+
static IEnumerable<JValue> GetLeafValuesFromJArray(JArray jArray)
97+
{
98+
for (var i = 0; i < jArray.Count; i++)
99+
{
100+
foreach (var result in GetLeafValues(jArray[i]))
101+
{
102+
yield return result;
103+
}
104+
}
105+
}
104106

105-
static IEnumerable<JValue> GetLeafValuesFromJArray(JArray jArray)
106-
{
107-
for (var i = 0; i < jArray.Count; i++)
108-
{
109-
foreach (var result in GetLeafValues(jArray[i]))
110-
{
111-
yield return result;
112-
}
113-
}
114-
}
107+
static IEnumerable<JValue> GetLeafValuesFromJProperty(JProperty jProperty)
108+
{
109+
foreach (var result in GetLeafValues(jProperty.Value))
110+
{
111+
yield return result;
112+
}
113+
}
115114

116-
static IEnumerable<JValue> GetLeafValuesFromJProperty(JProperty jProperty)
117-
{
118-
foreach (var result in GetLeafValues(jProperty.Value))
119-
{
120-
yield return result;
121-
}
122-
}
115+
static IEnumerable<JValue> GetLeafValuesFromJObject(JObject jObject)
116+
{
117+
foreach (var jToken in jObject.Children())
118+
{
119+
foreach (var result in GetLeafValues(jToken))
120+
{
121+
yield return result;
122+
}
123+
}
124+
}
123125

124-
static IEnumerable<JValue> GetLeafValuesFromJObject(JObject jObject)
125-
{
126-
foreach (var jToken in jObject.Children())
127-
{
128-
foreach (var result in GetLeafValues(jToken))
129-
{
130-
yield return result;
131-
}
132-
}
133-
}
134-
135-
#endregion
126+
#endregion
136127
}

EliteAPI/Main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
 Console.WriteLine("Hello");
1+
Console.WriteLine("Hello");

EliteVA/Plugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class Plugin : VoiceAttackPlugin
77
{
88
public override async Task OnStart(IVoiceAttackProxy proxy)
99
{
10-
10+
1111
}
1212
}
1313

VoiceAttack/Audio/VoiceAttackSpeech.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal VoiceAttackSpeech(dynamic proxy)
1515
/// <param name="type">Which audio to return</param>
1616
public Task<MemoryStream> GetCapturedAudio(AudioType type)
1717
{
18-
return Task.FromResult(_proxy.Utility.CapturedAudio((int) type));
18+
return Task.FromResult(_proxy.Utility.CapturedAudio((int)type));
1919
}
2020

2121
/// <summary>

VoiceAttack/Commands/VoiceAttackCommands.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal VoiceAttackCommands(dynamic proxy)
1212
}
1313

1414
public event EventHandler? OnCommandInvoked;
15-
15+
1616
/// <summary>
1717
/// The total amount of commands executed in this session
1818
/// </summary>
@@ -160,7 +160,7 @@ public Task<bool> CategoryExists(string name)
160160
{
161161
return Task.FromResult(_proxy.Command.CategoryExists(name));
162162
}
163-
163+
164164
public struct SetCommand
165165
{
166166
public SetCommand(DateTime timestamp, string command)
@@ -170,23 +170,23 @@ public SetCommand(DateTime timestamp, string command)
170170
}
171171

172172
public DateTime Timestamp { get; }
173-
173+
174174
public string Command { get; }
175175
}
176176
}
177177

178178
public enum CommandSource
179179
{
180-
Spoken,
181-
Keyboard,
182-
Joystick,
183-
Mouse,
180+
Spoken,
181+
Keyboard,
182+
Joystick,
183+
Mouse,
184184
Profile,
185185
External,
186-
Unrecognized,
187-
ProfileUnloadChange,
186+
Unrecognized,
187+
ProfileUnloadChange,
188188
ProfileUnloadClose,
189-
DictationRecognized,
190-
Plugin,
189+
DictationRecognized,
190+
Plugin,
191191
Other
192192
}

VoiceAttack/Options/VoiceAttackOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal VoiceAttackOptions(dynamic proxy)
1313
/// Whether plugins are enabled
1414
/// </summary>
1515
public bool PluginsEnabled => _proxy.PluginsEnabled;
16-
16+
1717
/// <summary>
1818
/// Whether the use of nested tokens is enabled
1919
/// </summary>

VoiceAttack/Process/VoiceAttackActiveWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal VoiceAttackActiveWindow(dynamic proxy)
1212
/// <summary>
1313
/// The title of the window
1414
/// </summary>
15-
public string Title => _proxy.Utility.ActiveWindowTitle( );
15+
public string Title => _proxy.Utility.ActiveWindowTitle();
1616

1717
/// <summary>
1818
/// The name of the process of the window

0 commit comments

Comments
 (0)