-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#18 Applying of JsonConfig with muliple drivers fails when applied to…
… AtataContext.GlobalConfiguration; Add tests: Driver_Chrome_ThruGlobalConfiguration, Driver_Chrome_ThruGlobalConfiguration_VerifyJsonConfig and Driver_Multiple_ThruGlobalConfiguration
- Loading branch information
1 parent
a0f657c
commit c7981fd
Showing
5 changed files
with
193 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Atata.Configuration.Json/JsonConfigContractResolver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Reflection; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Serialization; | ||
|
||
namespace Atata.Configuration.Json | ||
{ | ||
internal class JsonConfigContractResolver : DefaultContractResolver | ||
{ | ||
public static JsonConfigContractResolver Instance { get; } = new JsonConfigContractResolver(); | ||
|
||
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) | ||
{ | ||
JsonProperty property = base.CreateProperty(member, memberSerialization); | ||
|
||
if (property.DeclaringType.IsGenericType && property.DeclaringType.GetGenericTypeDefinition() == typeof(JsonConfig<>) && property.PropertyName == nameof(JsonConfig.Driver)) | ||
property.ShouldSerialize = _ => false; | ||
|
||
return property; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters