From d9866c2fa9bcb2c9ce609d11ab73e6ad3a9f3099 Mon Sep 17 00:00:00 2001 From: watsonb8 Date: Fri, 14 Jun 2024 10:27:41 -0500 Subject: [PATCH] Moving common code to shared lib --- automated-testing-demo.sln | 6 +++++ consumer/consumer.csproj | 4 ++++ producer/Model/DataModel.cs | 18 --------------- producer/Serializer/JsonSerializer.cs | 22 ------------------- producer/producer.csproj | 4 ++++ {consumer => shared}/Model/DataModel.cs | 0 .../Serializer/JsonSerializer.cs | 0 shared/shared.csproj | 13 +++++++++++ 8 files changed, 27 insertions(+), 40 deletions(-) delete mode 100644 producer/Model/DataModel.cs delete mode 100644 producer/Serializer/JsonSerializer.cs rename {consumer => shared}/Model/DataModel.cs (100%) rename {consumer => shared}/Serializer/JsonSerializer.cs (100%) create mode 100644 shared/shared.csproj diff --git a/automated-testing-demo.sln b/automated-testing-demo.sln index 8a46852..23f967e 100644 --- a/automated-testing-demo.sln +++ b/automated-testing-demo.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "producer", "producer\produc EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "consumer", "consumer\consumer.csproj", "{1F8DAF6D-67B2-43C4-ACFD-38B8541722C3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "shared", "shared\shared.csproj", "{6958D7C2-23D8-4383-9F03-6395DE86FD63}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -24,5 +26,9 @@ Global {1F8DAF6D-67B2-43C4-ACFD-38B8541722C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {1F8DAF6D-67B2-43C4-ACFD-38B8541722C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {1F8DAF6D-67B2-43C4-ACFD-38B8541722C3}.Release|Any CPU.Build.0 = Release|Any CPU + {6958D7C2-23D8-4383-9F03-6395DE86FD63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6958D7C2-23D8-4383-9F03-6395DE86FD63}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6958D7C2-23D8-4383-9F03-6395DE86FD63}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6958D7C2-23D8-4383-9F03-6395DE86FD63}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/consumer/consumer.csproj b/consumer/consumer.csproj index 42e331e..0d62398 100644 --- a/consumer/consumer.csproj +++ b/consumer/consumer.csproj @@ -12,4 +12,8 @@ + + + + diff --git a/producer/Model/DataModel.cs b/producer/Model/DataModel.cs deleted file mode 100644 index 7e473f3..0000000 --- a/producer/Model/DataModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Model -{ - public class DataModel - { - public DataModel(string id) - { - this.id = id; - } - - public string id { get; set; } - - public string? name { get; set; } - - public string? description { get; set; } - - public string? notes { get; set; } - } -} \ No newline at end of file diff --git a/producer/Serializer/JsonSerializer.cs b/producer/Serializer/JsonSerializer.cs deleted file mode 100644 index f2ac15c..0000000 --- a/producer/Serializer/JsonSerializer.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Confluent.Kafka; -using System.Text.Json; - -namespace Serializers -{ - public class JsonSerializer : ISerializer, IDeserializer - { - public byte[] Serialize(T data, SerializationContext context) - { - return JsonSerializer.SerializeToUtf8Bytes(data); - } - - public T Deserialize(ReadOnlySpan data, bool isNull, SerializationContext context) - { - if (!isNull) - { - return JsonSerializer.Deserialize(data); - } - throw new Exception ("Data cannot be null"); - } - } -} \ No newline at end of file diff --git a/producer/producer.csproj b/producer/producer.csproj index 1a950b2..3c33d07 100644 --- a/producer/producer.csproj +++ b/producer/producer.csproj @@ -11,4 +11,8 @@ + + + + diff --git a/consumer/Model/DataModel.cs b/shared/Model/DataModel.cs similarity index 100% rename from consumer/Model/DataModel.cs rename to shared/Model/DataModel.cs diff --git a/consumer/Serializer/JsonSerializer.cs b/shared/Serializer/JsonSerializer.cs similarity index 100% rename from consumer/Serializer/JsonSerializer.cs rename to shared/Serializer/JsonSerializer.cs diff --git a/shared/shared.csproj b/shared/shared.csproj new file mode 100644 index 0000000..fdab8e5 --- /dev/null +++ b/shared/shared.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + +