Skip to content

Commit

Permalink
Included parameterless constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oren (electricessence) committed Jan 17, 2020
1 parent 80901fc commit 48b79f4
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,4 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/
/.vscode
6 changes: 5 additions & 1 deletion Open.Serialization.Json.Newtonsoft/JsonSerializerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ public class JsonSerializerFactory : IJsonSerializerFactory, IJsonObjectSerializ
{
static readonly JsonSerializerSettings DefaultOptions = RelaxedJson.Options();
readonly JsonSerializerSettings _settings;
public JsonSerializerFactory(JsonSerializerSettings? defaultOptions = null)
public JsonSerializerFactory(JsonSerializerSettings? defaultOptions)
{
_settings = defaultOptions?.Clone() ?? DefaultOptions;
}

public JsonSerializerFactory() : this(null)
{
}

JsonSerializerInternal? _defaultSerializer;
internal JsonSerializerInternal DefaultSerializer
=> LazyInitializer.EnsureInitialized(ref _defaultSerializer, () => new JsonSerializerInternal(_settings))!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<RepositoryUrl>https://github.com/electricessence/Open.Serialization</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>serialization json newtonsoft</PackageTags>
<Version>2.2.3</Version>
<Version>2.2.4</Version>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
6 changes: 5 additions & 1 deletion Open.Serialization.Json.System/JsonSerializerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ public class JsonSerializerFactory : IJsonSerializerFactory
{
static readonly JsonSerializerOptions DefaultOptions = RelaxedJson.Options();
readonly JsonSerializerOptions _options;
public JsonSerializerFactory(JsonSerializerOptions? defaultOptions = null)
public JsonSerializerFactory(JsonSerializerOptions? defaultOptions)
{
_options = defaultOptions?.Clone() ?? DefaultOptions;
}

public JsonSerializerFactory() : this(null)
{
}

JsonSerializerInternal? _caseSensitive;
JsonSerializerInternal? _ignoreCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Part of the "Open" set of libraries.
<RepositoryUrl>https://github.com/electricessence/Open.Serialization</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>serialization json stj</PackageTags>
<Version>2.2.2</Version>
<Version>2.2.4</Version>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
6 changes: 5 additions & 1 deletion Open.Serialization.Json.Utf8Json/JsonSerializerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ public class JsonSerializerFactory : IJsonSerializerFactory
{
readonly IJsonFormatterResolver _resolver;
readonly bool _indent;
public JsonSerializerFactory(IJsonFormatterResolver? defaultResolver = null, bool indent = false)
public JsonSerializerFactory(IJsonFormatterResolver? defaultResolver, bool indent = false)
{
_resolver = defaultResolver ?? StandardResolver.Default;
if (_resolver == StandardResolver.ExcludeNullSnakeCase || _resolver == StandardResolver.SnakeCase)
throw new ArgumentOutOfRangeException(nameof(defaultResolver), "Snake case is not supported.");
_indent = indent;
}

public JsonSerializerFactory() : this(null)
{
}

JsonSerializerInternal? _defaultSerializer;
JsonSerializerInternal DefaultSerializer
=> LazyInitializer.EnsureInitialized(ref _defaultSerializer, () => new JsonSerializerInternal(_resolver, _indent))!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Part of the "Open" set of libraries.
<RepositoryUrl>https://github.com/electricessence/Open.Serialization</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>serialization json utf8json</PackageTags>
<Version>2.2.3</Version>
<Version>2.2.4</Version>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down

0 comments on commit 48b79f4

Please sign in to comment.