Skip to content

Commit

Permalink
Merge pull request #25 from atc-net/release/v1.5
Browse files Browse the repository at this point in the history
Release of new minor version v1.5
  • Loading branch information
LarsSkovslund authored Jul 5, 2022
2 parents cd5a254 + ff1afe6 commit 8bea3cd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Introduced configuration of custom json converters (#23)

## [1.4.5] - 2022-03-18

### Changed
Expand Down
10 changes: 9 additions & 1 deletion src/Atc.Cosmos.EventStore/Cosmos/CosmosEventSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Atc.Cosmos.EventStore.Converters;
using Atc.Cosmos.EventStore.Events;
using Microsoft.Azure.Cosmos;
using Microsoft.Extensions.Options;

namespace Atc.Cosmos.EventStore.Cosmos
{
Expand All @@ -16,7 +17,9 @@ internal class CosmosEventSerializer : CosmosSerializer
{
private readonly JsonSerializerOptions jsonSerializerOptions;

public CosmosEventSerializer(IEventTypeProvider typeProvider)
public CosmosEventSerializer(
IOptions<EventStoreClientOptions> options,
IEventTypeProvider typeProvider)
{
jsonSerializerOptions = new JsonSerializerOptions
{
Expand All @@ -30,6 +33,11 @@ public CosmosEventSerializer(IEventTypeProvider typeProvider)
jsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
jsonSerializerOptions.Converters.Add(new StreamIdConverter());
jsonSerializerOptions.Converters.Add(new StreamVersionConverter());

foreach (var converter in options.Value.CustomJsonConverter)
{
jsonSerializerOptions.Converters.Add(converter);
}
}

[return: MaybeNull]
Expand Down
7 changes: 7 additions & 0 deletions src/Atc.Cosmos.EventStore/EventStoreClientOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Azure.Core;
using Microsoft.Azure.Cosmos;

Expand Down Expand Up @@ -43,6 +45,11 @@ public string? ConnectionString

public CosmosClientOptions CosmosClientOptions { get; set; } = new CosmosClientOptions();

/// <summary>
/// Gets collections of custom <seealso cref="JsonConverter"/>.
/// </summary>
public ICollection<JsonConverter> CustomJsonConverter { get; } = new List<JsonConverter>();

public string? Endpoint { get; private set; }

public string? AuthKey { get; private set; }
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.4",
"version": "1.5",
"assemblyVersion": {
"precision": "revision"
},
Expand Down

0 comments on commit 8bea3cd

Please sign in to comment.