Skip to content

Commit

Permalink
#86 (comment): added extra constraint (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
masesdevelopers authored Oct 13, 2023
1 parent 17b43d8 commit f81416b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/net/KEFCore.SerDes/IValueContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

namespace MASES.EntityFrameworkCore.KNet.Serialization;
/// <summary>
/// This is the main interface a class must implmenet to be a ValueContainer. More info <see href="https://masesgroup.github.io/KEFCore/articles/serialization.html">here</see>
/// This is the main interface a class must implement to be a ValueContainer. More info <see href="https://masesgroup.github.io/KEFCore/articles/serialization.html">here</see>
/// </summary>
/// <typeparam name="T">It is the key <see cref="Type"/> passed from Entity Framework associated to the Entity data will be stored in the ValueContainer</typeparam>
public interface IValueContainer<in T> where T : notnull
{
/// <summary>
/// Returns back the raw data associated to the Entity
/// </summary>
/// <param name="tName">The <see cref="IEntityType"/> requesting to get the data back</param>
/// <param name="tName">The requesting <see cref="IEntityType"/> to get the data back</param>
/// <param name="array">The array of object to be filled in with the data stored in the ValueContainer</param>
void GetData(IEntityType tName, ref object[] array);
}
8 changes: 4 additions & 4 deletions src/net/KEFCore/Storage/Internal/EntityTypeProducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ namespace MASES.EntityFrameworkCore.KNet.Storage.Internal;
public class EntityTypeProducer<TKey, TValueContainer, TKeySerializer, TValueSerializer> : IEntityTypeProducer
where TKey : notnull
where TValueContainer : class, IValueContainer<TKey>
where TKeySerializer : class
where TValueSerializer : class
where TKeySerializer : class, new()
where TValueSerializer : class, new()
{
private readonly ConstructorInfo TValueContainerConstructor;
private readonly bool _useCompactedReplicator;
Expand Down Expand Up @@ -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<TKey>;
_valueSerdes = Activator.CreateInstance(typeof(TValueSerializer)) as IKNetSerDes<TValueContainer>;
_keySerdes = new TKeySerializer() as IKNetSerDes<TKey>;

Check warning on line 195 in src/net/KEFCore/Storage/Internal/EntityTypeProducer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Possible null reference assignment.
_valueSerdes = new TValueSerializer() as IKNetSerDes<TValueContainer>;

if (_useCompactedReplicator)
{
Expand Down
8 changes: 4 additions & 4 deletions src/net/KEFCore/Storage/Internal/EntityTypeProducers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class EntityTypeProducers
public static IEntityTypeProducer Create<TKey, TValueContainer, TKeySerializer, TValueSerializer>(IEntityType entityType, IKafkaCluster cluster)
where TKey : notnull
where TValueContainer : class, IValueContainer<TKey>
where TKeySerializer : class
where TValueSerializer : class
where TKeySerializer : class, new()
where TValueSerializer : class, new()
{
return _producers.GetOrAdd(entityType, _ => CreateProducerLocal<TKey, TValueContainer, TKeySerializer, TValueSerializer>(entityType, cluster));
}
Expand All @@ -54,7 +54,7 @@ public static void Dispose(IEntityTypeProducer producer)
static IEntityTypeProducer CreateProducerLocal<TKey, TValueContainer, TKeySerializer, TValueSerializer>(IEntityType entityType, IKafkaCluster cluster)
where TKey : notnull
where TValueContainer : class, IValueContainer<TKey>
where TKeySerializer : class
where TValueSerializer : class
where TKeySerializer : class, new()
where TValueSerializer : class, new()
=> new EntityTypeProducer<TKey, TValueContainer, TKeySerializer, TValueSerializer>(entityType, cluster);
}
4 changes: 2 additions & 2 deletions src/net/KEFCore/Storage/Internal/KafkaTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ namespace MASES.EntityFrameworkCore.KNet.Storage.Internal;
public class KafkaTable<TKey, TValueContainer, TKeySerializer, TValueSerializer> : IKafkaTable
where TKey : notnull
where TValueContainer : class, IValueContainer<TKey>
where TKeySerializer : class
where TValueSerializer : class
where TKeySerializer : class, new()
where TValueSerializer : class, new()
{
private readonly IPrincipalKeyValueFactory<TKey> _keyValueFactory;
private readonly bool _sensitiveLoggingEnabled;
Expand Down
4 changes: 2 additions & 2 deletions src/net/KEFCore/Storage/Internal/KafkaTableFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static Func<IKafkaTable> CreateFactory<TKey, TValueContainer, TKeySerial
bool sensitiveLoggingEnabled)
where TKey : notnull
where TValueContainer : class, IValueContainer<TKey>
where TKeySerializer : class
where TValueSerializer : class
where TKeySerializer : class, new()
where TValueSerializer : class, new()
=> () => new KafkaTable<TKey, TValueContainer, TKeySerializer, TValueSerializer>(cluster, entityType, sensitiveLoggingEnabled);
}

0 comments on commit f81416b

Please sign in to comment.