Skip to content

Commit 4e40676

Browse files
committed
Run csharpier.
1 parent 6edb3ab commit 4e40676

13 files changed

Lines changed: 301 additions & 140 deletions

SonyAudioControlApi/Api/GetCustomEqualizerSettings.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ public sealed partial class Api
88
/// <summary>
99
/// Gets information about the current custom equalizer settings.
1010
/// </summary>
11-
public async Task<CustomEqualizerSettingsResult[]> GetCustomEqualizerSettingsAsync(CustomEqualizerSettingsResult.EqualizerTarget target = CustomEqualizerSettingsResult.EqualizerTarget.AllTargets)
11+
public async Task<CustomEqualizerSettingsResult[]> GetCustomEqualizerSettingsAsync(
12+
CustomEqualizerSettingsResult.EqualizerTarget target =
13+
CustomEqualizerSettingsResult.EqualizerTarget.AllTargets
14+
)
1215
{
1316
return await this.makeRequestAsync<CustomEqualizerSettingsResult[]>(
1417
ApiLib.Audio,
1518
ApiVersion.V10,
1619
"getCustomEqualizerSettings",
17-
new CustomEqualizerSettingsProps() { Target = target }
20+
new CustomEqualizerSettingsProps() { Target = target }
1821
);
1922
}
2023
}

SonyAudioControlApi/Api/GetInterfaceInformation.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,5 @@ public enum DeviceCategory
9898
/// </summary>
9999
[JsonPropertyName("serverName")]
100100
public string ServerName { get; set; }
101-
102101
}
103102
}
104-

SonyAudioControlApi/Api/GetPlaybackModeSettings.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public sealed partial class Api
1919
/// If this is null or "" is set, it means all sources for the mode.
2020
/// </param>
2121
public async Task<PlaybackModeSettingsResult[]> GetPlaybackModeSettingsAsync(
22-
PlaybackModeSettingsResult.PlaybackTarget target = PlaybackModeSettingsResult.PlaybackTarget.AllTargets,
22+
PlaybackModeSettingsResult.PlaybackTarget target =
23+
PlaybackModeSettingsResult.PlaybackTarget.AllTargets,
2324
string uri = null
2425
)
2526
{

SonyAudioControlApi/Api/GetPlayingContentInfo.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public sealed partial class Api
1717
/// <remarks>
1818
/// Only extInput:* sources have types implemented.
1919
/// </remarks>
20-
public async Task<PlayingContentInfoResult[]> GetPlayingContentInfoAsync(string output = null)
20+
public async Task<PlayingContentInfoResult[]> GetPlayingContentInfoAsync(
21+
string output = null
22+
)
2123
{
2224
return await this.makeRequestAsync<PlayingContentInfoResult[]>(
2325
ApiLib.AvContent,
@@ -36,7 +38,8 @@ internal sealed class PlayingContentInfoProps
3638

3739
public sealed class PlayingContentInfoResult
3840
{
39-
public class PlayingContentStateInfo {
41+
public class PlayingContentStateInfo
42+
{
4043
[JsonEnumConverter]
4144
public enum PlayingContentState
4245
{

SonyAudioControlApi/Api/GetVolumeInformation.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,4 @@ public enum MuteStatus
101101
[JsonPropertyName("volume")]
102102
public int Volume { get; set; }
103103
}
104-
105104
}

SonyAudioControlApi/Api/Util/NotificationManager.cs

Lines changed: 220 additions & 102 deletions
Large diffs are not rendered by default.

SonyAudioControlApi/Api/Util/Request.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ public RequestObject(string method, ApiVersion version, object @params)
5858
[JsonIgnore]
5959
public string Serialized
6060
{
61-
get
62-
{
63-
return JsonSerializer.Serialize(this);
64-
}
61+
get { return JsonSerializer.Serialize(this); }
6562
}
6663
}
6764

@@ -81,7 +78,12 @@ private class ResponseObject<TResponse> : SlimResponseObject
8178
public TResponse Result { get; set; }
8279
}
8380

84-
private async Task<TResult> makeRequestAsync<TResult>(ApiLib lib, ApiVersion version, string method, object @params = null)
81+
private async Task<TResult> makeRequestAsync<TResult>(
82+
ApiLib lib,
83+
ApiVersion version,
84+
string method,
85+
object @params = null
86+
)
8587
{
8688
if (this.Device is null)
8789
{
@@ -98,13 +100,19 @@ private async Task<TResult> makeRequestAsync<TResult>(ApiLib lib, ApiVersion ver
98100
string libName = Utilities.GetApiLibName(lib);
99101
string requestUrl = $"http://{this.Device.Hostname}:{this.Device.Port}/sony/{libName}";
100102

101-
HttpContent httpContent = new StringContent(requestObject.Serialized, Encoding.UTF8, "application/json");
103+
HttpContent httpContent = new StringContent(
104+
requestObject.Serialized,
105+
Encoding.UTF8,
106+
"application/json"
107+
);
102108
using (HttpClient httpClient = new HttpClient())
103109
{
104110
HttpResponseMessage response = await httpClient.PostAsync(requestUrl, httpContent);
105111
if (response.IsSuccessStatusCode)
106112
{
107-
ResponseObject<TResult> responseObject = JsonSerializer.Deserialize<ResponseObject<TResult>>(await response.Content.ReadAsStringAsync());
113+
ResponseObject<TResult> responseObject = JsonSerializer.Deserialize<
114+
ResponseObject<TResult>
115+
>(await response.Content.ReadAsStringAsync());
108116
if (responseObject.Error != null)
109117
{
110118
// TODO - handle

SonyAudioControlApi/EnumConverter.cs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ internal sealed class JsonEnumConverterAttribute : JsonConverterAttribute
2828
{
2929
public override JsonConverter CreateConverter(Type typeToConvert)
3030
{
31-
return Activator.CreateInstance(typeof(EnumConverter<>).MakeGenericType(typeToConvert)) as JsonConverter;
31+
return Activator.CreateInstance(typeof(EnumConverter<>).MakeGenericType(typeToConvert))
32+
as JsonConverter;
3233
}
3334
}
3435

35-
internal sealed class EnumConverter<TEnum> : JsonConverter<TEnum> where TEnum : struct
36+
internal sealed class EnumConverter<TEnum> : JsonConverter<TEnum>
37+
where TEnum : struct
3638
{
37-
private static Dictionary<Type, MappingConfiguration> _mappings = new Dictionary<Type, MappingConfiguration>();
39+
private static Dictionary<Type, MappingConfiguration> _mappings =
40+
new Dictionary<Type, MappingConfiguration>();
3841

3942
private struct MappingConfiguration
4043
{
@@ -43,7 +46,6 @@ private struct MappingConfiguration
4346
public Dictionary<TEnum, string> EnumToStringMapping { get; set; }
4447
}
4548

46-
4749
private static MappingConfiguration tryGetMappingForType(Type type)
4850
{
4951
if (!EnumConverter<TEnum>._mappings.ContainsKey(type))
@@ -63,7 +65,8 @@ private static MappingConfiguration tryGetMappingForType(Type type)
6365
FieldInfo memberField = member as FieldInfo;
6466
if (memberField != null && memberField.IsStatic && memberField.IsPublic)
6567
{
66-
EnumJsonStringValueAttribute attribute = member.GetCustomAttribute<EnumJsonStringValueAttribute>();
68+
EnumJsonStringValueAttribute attribute =
69+
member.GetCustomAttribute<EnumJsonStringValueAttribute>();
6770
if (attribute == null)
6871
{
6972
// We've found an element without the attribute
@@ -87,7 +90,9 @@ private static MappingConfiguration getMappingForType(Type type)
8790
MappingConfiguration mapping = EnumConverter<TEnum>.tryGetMappingForType(type);
8891
if (!mapping.MappingIsValid)
8992
{
90-
throw new Exception($"Unable to initialize {type} mapping. A member is missing the EnumStringValueAttribute");
93+
throw new Exception(
94+
$"Unable to initialize {type} mapping. A member is missing the EnumStringValueAttribute"
95+
);
9196
}
9297
else
9398
{
@@ -100,7 +105,11 @@ public override bool CanConvert(Type type)
100105
return tryGetMappingForType(type).MappingIsValid;
101106
}
102107

103-
public override TEnum Read(ref Utf8JsonReader reader, Type type, JsonSerializerOptions options)
108+
public override TEnum Read(
109+
ref Utf8JsonReader reader,
110+
Type type,
111+
JsonSerializerOptions options
112+
)
104113
{
105114
MappingConfiguration mapping = EnumConverter<TEnum>.getMappingForType(type);
106115

@@ -118,12 +127,18 @@ public override TEnum Read(ref Utf8JsonReader reader, Type type, JsonSerializerO
118127
}
119128
}
120129

121-
public override void Write(Utf8JsonWriter writer, TEnum value, JsonSerializerOptions options)
130+
public override void Write(
131+
Utf8JsonWriter writer,
132+
TEnum value,
133+
JsonSerializerOptions options
134+
)
122135
{
123136
Type valueType = value.GetType();
124137
if (valueType.IsArray)
125138
{
126-
MappingConfiguration mapping = EnumConverter<TEnum>.getMappingForType(valueType.GetElementType());
139+
MappingConfiguration mapping = EnumConverter<TEnum>.getMappingForType(
140+
valueType.GetElementType()
141+
);
127142
TEnum[] typedValueArray = value as TEnum[];
128143
if (typedValueArray != null)
129144
{

SonyAudioControlApi/Exceptions/HttpException.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44

55
namespace SonyAudioControlApi.Exceptions
66
{
7-
class HttpException : Exception
8-
{
9-
}
7+
class HttpException : Exception { }
108
}

SonyAudioControlApi/Exceptions/UnexpectedResponseException.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ namespace SonyAudioControlApi.Exceptions
66
{
77
public class UnexpectedResponseException : Exception
88
{
9-
internal UnexpectedResponseException(string property, string actualValue) :
10-
base($"Recieved unexpected value \"{actualValue}\" for property \"{property}\".")
11-
{
12-
}
9+
internal UnexpectedResponseException(string property, string actualValue)
10+
: base($"Recieved unexpected value \"{actualValue}\" for property \"{property}\".") { }
1311
}
1412
}

0 commit comments

Comments
 (0)