-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing comments to public methods
- Loading branch information
Showing
14 changed files
with
174 additions
and
18 deletions.
There are no files selected for viewing
10 changes: 8 additions & 2 deletions
10
src/RocksDb.Extensions.ProtoBufNet/ProtoBufNetSerializerFactory.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 |
---|---|---|
@@ -1,18 +1,24 @@ | ||
using System; | ||
using ProtoBuf.Meta; | ||
|
||
namespace RocksDb.Extensions.ProtoBufNet; | ||
|
||
/// <summary> | ||
/// A factory class for creating ProtoBuf-Net serializers. | ||
/// </summary> | ||
public class ProtoBufNetSerializerFactory : ISerializerFactory | ||
{ | ||
/// <inheritdoc/> | ||
public bool CanCreateSerializer<T>() | ||
{ | ||
// Checks if ProtoBuf-Net can serialize the specified type. | ||
return RuntimeTypeModel.Default.CanSerialize(typeof(T)); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public ISerializer<T> CreateSerializer<T>() | ||
{ | ||
// Creates an instance of the ProtoBufNetSerializer with the specified type. | ||
var type = typeof(ProtoBufNetSerializer<>).MakeGenericType(typeof(T)); | ||
return (ISerializer<T>) Activator.CreateInstance(type); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
using System; | ||
using System.Buffers; | ||
using Google.Protobuf; | ||
|
||
|
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
1 change: 0 additions & 1 deletion
1
src/RocksDb.Extensions.System.Text.Json/SystemTextJsonSerializer.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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
using System; | ||
using System.Buffers; | ||
using System.Text.Json; | ||
|
||
|
18 changes: 12 additions & 6 deletions
18
src/RocksDb.Extensions.System.Text.Json/SystemTextJsonSerializerFactory.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 |
---|---|---|
@@ -1,27 +1,33 @@ | ||
using System; | ||
using System.Text.Json; | ||
|
||
namespace RocksDb.Extensions.System.Text.Json; | ||
|
||
/// <summary> | ||
/// A serializer factory implementation that creates instances of SystemTextJsonSerializer for any type. | ||
/// </summary> | ||
public class SystemTextJsonSerializerFactory : ISerializerFactory | ||
{ | ||
private readonly JsonSerializerOptions? _options; | ||
|
||
|
||
/// <summary> | ||
/// Initializes a new instance of the SystemTextJsonSerializerFactory class with optional JsonSerializerOptions. | ||
/// </summary> | ||
/// <param name="options">Optional JsonSerializerOptions to use for serialization.</param> | ||
public SystemTextJsonSerializerFactory(JsonSerializerOptions? options = null) | ||
{ | ||
_options = options; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public bool CanCreateSerializer<T>() | ||
{ | ||
return true; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public ISerializer<T> CreateSerializer<T>() | ||
{ | ||
var type = typeof(SystemTextJsonSerializer<>).MakeGenericType(typeof(T)); | ||
return (ISerializer<T>)Activator.CreateInstance(type, _options); | ||
return (ISerializer<T>) Activator.CreateInstance(type, _options); | ||
} | ||
|
||
|
||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
namespace RocksDb.Extensions; | ||
|
||
/// <summary> | ||
/// A builder that can be used to create a RocksDB instance with one or more stores. | ||
/// </summary> | ||
public interface IRocksDbBuilder | ||
{ | ||
/// <summary> | ||
/// Adds a RocksDB store to the builder for the specified column family. | ||
/// </summary> | ||
/// <param name="columnFamily"></param> | ||
/// <typeparam name="TKey">The type of the store's key.</typeparam> | ||
/// <typeparam name="TValue">The type of the store's value.</typeparam> | ||
/// <typeparam name="TStore">The type of the store to add.</typeparam> | ||
/// <returns>The builder instance for method chaining</returns> | ||
/// <remarks> | ||
/// The <typeparamref name="TStore"/> type must be a concrete implementation of the abstract class | ||
/// <see cref="RocksDbStore{TKey,TValue}"/>. | ||
/// </remarks> | ||
IRocksDbBuilder AddStore<TKey, TValue, TStore>(string columnFamily) where TStore : RocksDbStore<TKey, TValue>; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
namespace RocksDb.Extensions; | ||
|
||
/// <summary> | ||
/// Defines an interface for a serializer factory that can create serializers for a given type. | ||
/// </summary> | ||
public interface ISerializerFactory | ||
{ | ||
/// <summary> | ||
/// Determines whether this factory can create a serializer for the specified type. | ||
/// </summary> | ||
/// <typeparam name="T">The type to create a serializer for.</typeparam> | ||
/// <returns><c>true</c> if this factory can create a serializer for the specified type; otherwise, <c>false</c>.</returns> | ||
bool CanCreateSerializer<T>(); | ||
|
||
/// <summary> | ||
/// Creates a serializer for the specified type. | ||
/// </summary> | ||
/// <typeparam name="T">The type to create a serializer for.</typeparam> | ||
/// <returns>A serializer for the specified type.</returns> | ||
ISerializer<T> CreateSerializer<T>(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
namespace RocksDb.Extensions; | ||
|
||
/// <summary> | ||
/// Represents the configuration options for a RocksDB instance. | ||
/// </summary> | ||
public class RocksDbOptions | ||
{ | ||
public string Path { get; set; } | ||
internal List<string> ColumnFamilies { get; } = new(); | ||
/// <summary> | ||
/// A string that represents the path to the RocksDB instance on disk. | ||
/// </summary> | ||
public string Path { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// A list of <see cref="ISerializerFactory"/> instances that are used to serialize and deserialize data in the RocksDB instance. | ||
/// </summary> | ||
/// <remarks> | ||
/// At least one serializer factory must be registered before using the RocksDB instance. | ||
/// If no factory can create a serializer for any type defined by any of the registered stores, | ||
/// an <see cref="InvalidOperationException"/> will be thrown. | ||
/// </remarks> | ||
public List<ISerializerFactory> SerializerFactories { get; } = new(); | ||
} | ||
|
||
internal List<string> ColumnFamilies { get; } = new(); | ||
} |
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