Skip to content

Commit

Permalink
Add option to add custom type converters (#438)
Browse files Browse the repository at this point in the history
Co-authored-by: cognite-bulldozer[bot] <51074376+cognite-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
einarmo and cognite-bulldozer[bot] authored Jun 18, 2024
1 parent 5b83bf5 commit 205c564
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion Cognite.Config/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,28 @@ private static void Rebuild()
/// <typeparam name="T">Type to map to</typeparam>
public static void AddTagMapping<T>(string tag)
{
builder = builder.WithTagMapping(tag, typeof(T));
lock (_deserializerLock)
{
builder = builder.WithTagMapping(tag, typeof(T));
ignoreUnmatchedBuilder = ignoreUnmatchedBuilder.WithTagMapping(tag, typeof(T));
Rebuild();
}
}

/// <summary>
/// Adds a YAML type converter to the config deserializer.
/// </summary>
/// <param name="converter">Type converter to add</param>
public static void AddTypeConverter(IYamlTypeConverter converter)
{
lock (_deserializerLock)
{
builder = builder.WithTypeConverter(converter);
ignoreUnmatchedBuilder = ignoreUnmatchedBuilder.WithTypeConverter(converter);
Rebuild();
}
}

/// <summary>
/// Configures the deserializer to ignore unmatched properties.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.24.0
1.24.1

0 comments on commit 205c564

Please sign in to comment.