Skip to content

Commit d843c8a

Browse files
Refactor sources
1 parent bde850e commit d843c8a

File tree

8 files changed

+22
-22
lines changed

8 files changed

+22
-22
lines changed

src/Atata.Configuration.Json/JsonConfigContractResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Atata.Configuration.Json;
44

5-
internal class JsonConfigContractResolver : DefaultContractResolver
5+
internal sealed class JsonConfigContractResolver : DefaultContractResolver
66
{
77
public static JsonConfigContractResolver Instance { get; } = new JsonConfigContractResolver();
88

src/Atata.Configuration.Json/Mapping/AttributeMapper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ public class AttributeMapper
1010

1111
private readonly Assembly[] _assembliesToFindAttributeTypes;
1212

13-
private readonly IObjectCreator _objectCreator;
13+
private readonly ObjectCreator _objectCreator;
1414

1515
public AttributeMapper(string assemblyNamePatternToFindAttributeTypes, string defaultAssemblyNamePatternToFindTypes)
1616
{
1717
_assembliesToFindAttributeTypes = AssemblyFinder.FindAllByPattern(assemblyNamePatternToFindAttributeTypes);
1818

19-
IObjectConverter objectConverter = new ObjectConverter
19+
ObjectConverter objectConverter = new()
2020
{
2121
AssemblyNamePatternToFindTypes = defaultAssemblyNamePatternToFindTypes
2222
};
23-
IObjectMapper objectMapper = new ObjectMapper(objectConverter);
24-
_objectCreator = new ObjectCreator(objectConverter, objectMapper);
23+
ObjectMapper objectMapper = new(objectConverter);
24+
_objectCreator = new(objectConverter, objectMapper);
2525
}
2626

2727
public Attribute Map(AttributeJsonSection section)

src/Atata.Configuration.Json/Mapping/ChromiumDriverJsonMapper`3.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ protected override void MapOptions(DriverOptionsJsonSection section, TOptions op
1111
{
1212
base.MapOptions(section, options);
1313

14-
if (section.Arguments?.Any() ?? false)
14+
if (section.Arguments is { Length: > 0 })
1515
options.AddArguments(section.Arguments);
1616

17-
if (section.ExcludedArguments?.Any() ?? false)
17+
if (section.ExcludedArguments is { Length: > 0 })
1818
options.AddExcludedArguments(section.ExcludedArguments);
1919

20-
if (section.Extensions?.Any() ?? false)
20+
if (section.Extensions is { Length: > 0 })
2121
options.AddExtensions(section.Extensions);
2222

23-
if (section.EncodedExtensions?.Any() ?? false)
23+
if (section.EncodedExtensions is { Length: > 0 })
2424
options.AddEncodedExtensions(section.EncodedExtensions);
2525

26-
if (section.WindowTypes?.Any() ?? false)
26+
if (section.WindowTypes is { Length: > 0 })
2727
options.AddWindowTypes(section.WindowTypes);
2828

2929
if (section.PerformanceLoggingPreferences != null)
@@ -58,7 +58,7 @@ private void MapPerformanceLoggingPreferences(DriverPerformanceLoggingPreference
5858
{
5959
ObjectMapper.Map(section.ExtraPropertiesMap, preferences);
6060

61-
if (section.TracingCategories?.Any() ?? false)
61+
if (section.TracingCategories is { Length: > 0 })
6262
preferences.AddTracingCategories(section.TracingCategories);
6363
}
6464

src/Atata.Configuration.Json/Mapping/DriverJsonMapper`3.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected virtual void Map(DriverJsonSection section, TBuilder builder)
4646
if (section.CommandTimeout != null)
4747
builder.WithCommandTimeout(TimeSpan.FromSeconds(section.CommandTimeout.Value));
4848

49-
if (section.PortsToIgnore?.Any() ?? false)
49+
if (section.PortsToIgnore is { Length: > 0 })
5050
builder.WithPortsToIgnore(section.PortsToIgnore);
5151

5252
if (!string.IsNullOrWhiteSpace(section.Service?.DriverPath))
@@ -66,7 +66,7 @@ protected virtual void MapOptions(DriverOptionsJsonSection section, TOptions opt
6666
{
6767
var properties = section.ExtraPropertiesMap;
6868

69-
if (properties?.Any() ?? false)
69+
if (properties is { Count: > 0 })
7070
ObjectMapper.Map(properties, options);
7171

7272
if (section.Proxy != null)
@@ -81,7 +81,7 @@ protected virtual void MapOptions(DriverOptionsJsonSection section, TOptions opt
8181
options.AddAdditionalOption(item.Key, FillTemplateVariables(item.Value));
8282
}
8383

84-
if (section.LoggingPreferences?.Any() ?? false)
84+
if (section.LoggingPreferences is { Count: > 0 })
8585
{
8686
foreach (var item in section.LoggingPreferences)
8787
options.SetLoggingPreference(item.Key, item.Value);
@@ -92,15 +92,15 @@ private void MapProxy(ProxyJsonSection section, Proxy proxy)
9292
{
9393
ObjectMapper.Map(section.ExtraPropertiesMap, proxy);
9494

95-
if (section.BypassAddresses?.Any() ?? false)
95+
if (section.BypassAddresses is { Length: > 0 })
9696
proxy.AddBypassAddresses(section.BypassAddresses);
9797
}
9898

9999
protected virtual void MapService(DriverServiceJsonSection section, TService service)
100100
{
101101
var properties = section.ExtraPropertiesMap;
102102

103-
if (properties?.Any() ?? false)
103+
if (properties is { Count: > 0 })
104104
ObjectMapper.Map(properties, service);
105105
}
106106

src/Atata.Configuration.Json/Mapping/EventSubscriptionMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public sealed class EventSubscriptionMapper
66

77
private readonly Assembly[] _assembliesToFindEventHandlerTypes;
88

9-
private readonly IObjectCreator _objectCreator;
9+
private readonly ObjectCreator _objectCreator;
1010

1111
public EventSubscriptionMapper(
1212
string assemblyNamePatternToFindEventTypes,

src/Atata.Configuration.Json/Mapping/FirefoxDriverJsonMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected override void MapOptions(DriverOptionsJsonSection section, FirefoxOpti
1717
options.AddAdditionalFirefoxOption(item.Key, FillTemplateVariables(item.Value));
1818
}
1919

20-
if (section.Arguments?.Any() ?? false)
20+
if (section.Arguments is { Length: > 0 })
2121
options.AddArguments(section.Arguments);
2222

2323
if (section.Profile != null)

src/Atata.Configuration.Json/Mapping/JsonConfigMapper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,12 @@ private static void MapBrowserLogs(BrowserLogsJsonSection section, AtataContextB
294294

295295
private static object CreateObject(string typeName, Dictionary<string, object> valuesMap, string assemblyNamePatternToFindType)
296296
{
297-
IObjectConverter objectConverter = new ObjectConverter
297+
ObjectConverter objectConverter = new()
298298
{
299299
AssemblyNamePatternToFindTypes = assemblyNamePatternToFindType
300300
};
301-
IObjectMapper objectMapper = new ObjectMapper(objectConverter);
302-
IObjectCreator objectCreator = new ObjectCreator(objectConverter, objectMapper);
301+
ObjectMapper objectMapper = new(objectConverter);
302+
ObjectCreator objectCreator = new(objectConverter, objectMapper);
303303

304304
var assembliesToFindTypes = AssemblyFinder.FindAllByPattern(assemblyNamePatternToFindType);
305305
Type strategyType = TypeFinder.FindInAssemblies(typeName, assembliesToFindTypes);

test/Atata.Configuration.Json.Tests/Overrides/RemoteDriverContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public IDisposable UseNullDriver()
2323
return new DriverContextNullableSession(this);
2424
}
2525

26-
private class DriverContextNullableSession : IDisposable
26+
private sealed class DriverContextNullableSession : IDisposable
2727
{
2828
private readonly RemoteDriverContext _context;
2929

0 commit comments

Comments
 (0)