From f81416b22a0726d8b744a0a5f85c7b46a8935911 Mon Sep 17 00:00:00 2001
From: MASES Public Developers Team
<94312179+masesdevelopers@users.noreply.github.com>
Date: Fri, 13 Oct 2023 19:03:41 +0200
Subject: [PATCH]
https://github.com/masesgroup/KEFCore/issues/86#issuecomment-1761811117:
added extra constraint (#92)
---
src/net/KEFCore.SerDes/IValueContainer.cs | 4 ++--
src/net/KEFCore/Storage/Internal/EntityTypeProducer.cs | 8 ++++----
src/net/KEFCore/Storage/Internal/EntityTypeProducers.cs | 8 ++++----
src/net/KEFCore/Storage/Internal/KafkaTable.cs | 4 ++--
src/net/KEFCore/Storage/Internal/KafkaTableFactory.cs | 4 ++--
5 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/net/KEFCore.SerDes/IValueContainer.cs b/src/net/KEFCore.SerDes/IValueContainer.cs
index ce15befb..fa896495 100644
--- a/src/net/KEFCore.SerDes/IValueContainer.cs
+++ b/src/net/KEFCore.SerDes/IValueContainer.cs
@@ -20,7 +20,7 @@
namespace MASES.EntityFrameworkCore.KNet.Serialization;
///
-/// This is the main interface a class must implmenet to be a ValueContainer. More info here
+/// This is the main interface a class must implement to be a ValueContainer. More info here
///
/// It is the key passed from Entity Framework associated to the Entity data will be stored in the ValueContainer
public interface IValueContainer where T : notnull
@@ -28,7 +28,7 @@ public interface IValueContainer where T : notnull
///
/// Returns back the raw data associated to the Entity
///
- /// The requesting to get the data back
+ /// The requesting to get the data back
/// The array of object to be filled in with the data stored in the ValueContainer
void GetData(IEntityType tName, ref object[] array);
}
diff --git a/src/net/KEFCore/Storage/Internal/EntityTypeProducer.cs b/src/net/KEFCore/Storage/Internal/EntityTypeProducer.cs
index 1fa17f63..7af0426d 100644
--- a/src/net/KEFCore/Storage/Internal/EntityTypeProducer.cs
+++ b/src/net/KEFCore/Storage/Internal/EntityTypeProducer.cs
@@ -38,8 +38,8 @@ namespace MASES.EntityFrameworkCore.KNet.Storage.Internal;
public class EntityTypeProducer : IEntityTypeProducer
where TKey : notnull
where TValueContainer : class, IValueContainer
- where TKeySerializer : class
- where TValueSerializer : class
+ where TKeySerializer : class, new()
+ where TValueSerializer : class, new()
{
private readonly ConstructorInfo TValueContainerConstructor;
private readonly bool _useCompactedReplicator;
@@ -192,8 +192,8 @@ public EntityTypeProducer(IEntityType entityType, IKafkaCluster cluster)
var tTValueContainer = typeof(TValueContainer);
TValueContainerConstructor = tTValueContainer.GetConstructors().Single(ci => ci.GetParameters().Length == 2);
- _keySerdes = Activator.CreateInstance(typeof(TKeySerializer)) as IKNetSerDes;
- _valueSerdes = Activator.CreateInstance(typeof(TValueSerializer)) as IKNetSerDes;
+ _keySerdes = new TKeySerializer() as IKNetSerDes;
+ _valueSerdes = new TValueSerializer() as IKNetSerDes;
if (_useCompactedReplicator)
{
diff --git a/src/net/KEFCore/Storage/Internal/EntityTypeProducers.cs b/src/net/KEFCore/Storage/Internal/EntityTypeProducers.cs
index 08717a49..8ebfa800 100644
--- a/src/net/KEFCore/Storage/Internal/EntityTypeProducers.cs
+++ b/src/net/KEFCore/Storage/Internal/EntityTypeProducers.cs
@@ -36,8 +36,8 @@ public class EntityTypeProducers
public static IEntityTypeProducer Create(IEntityType entityType, IKafkaCluster cluster)
where TKey : notnull
where TValueContainer : class, IValueContainer
- where TKeySerializer : class
- where TValueSerializer : class
+ where TKeySerializer : class, new()
+ where TValueSerializer : class, new()
{
return _producers.GetOrAdd(entityType, _ => CreateProducerLocal(entityType, cluster));
}
@@ -54,7 +54,7 @@ public static void Dispose(IEntityTypeProducer producer)
static IEntityTypeProducer CreateProducerLocal(IEntityType entityType, IKafkaCluster cluster)
where TKey : notnull
where TValueContainer : class, IValueContainer
- where TKeySerializer : class
- where TValueSerializer : class
+ where TKeySerializer : class, new()
+ where TValueSerializer : class, new()
=> new EntityTypeProducer(entityType, cluster);
}
diff --git a/src/net/KEFCore/Storage/Internal/KafkaTable.cs b/src/net/KEFCore/Storage/Internal/KafkaTable.cs
index 8e0dfcd4..5dc97f6b 100644
--- a/src/net/KEFCore/Storage/Internal/KafkaTable.cs
+++ b/src/net/KEFCore/Storage/Internal/KafkaTable.cs
@@ -36,8 +36,8 @@ namespace MASES.EntityFrameworkCore.KNet.Storage.Internal;
public class KafkaTable : IKafkaTable
where TKey : notnull
where TValueContainer : class, IValueContainer
- where TKeySerializer : class
- where TValueSerializer : class
+ where TKeySerializer : class, new()
+ where TValueSerializer : class, new()
{
private readonly IPrincipalKeyValueFactory _keyValueFactory;
private readonly bool _sensitiveLoggingEnabled;
diff --git a/src/net/KEFCore/Storage/Internal/KafkaTableFactory.cs b/src/net/KEFCore/Storage/Internal/KafkaTableFactory.cs
index 261b51b0..280cd4a1 100644
--- a/src/net/KEFCore/Storage/Internal/KafkaTableFactory.cs
+++ b/src/net/KEFCore/Storage/Internal/KafkaTableFactory.cs
@@ -65,7 +65,7 @@ private static Func CreateFactory
- where TKeySerializer : class
- where TValueSerializer : class
+ where TKeySerializer : class, new()
+ where TValueSerializer : class, new()
=> () => new KafkaTable(cluster, entityType, sensitiveLoggingEnabled);
}