diff --git a/Bullet6/Bullet6.csproj b/Bullet6/Bullet6.csproj
index 2150e37..434708c 100644
--- a/Bullet6/Bullet6.csproj
+++ b/Bullet6/Bullet6.csproj
@@ -7,4 +7,8 @@
enable
+
+
+
+
diff --git a/Bullet6/IFlow.cs b/Bullet6/IFlow.cs
new file mode 100644
index 0000000..c60236c
--- /dev/null
+++ b/Bullet6/IFlow.cs
@@ -0,0 +1,4 @@
+public interface IFlow
+{
+ Task Start();
+}
diff --git a/Bullet6/Program.cs b/Bullet6/Program.cs
index 608cc9c..a9fce17 100644
--- a/Bullet6/Program.cs
+++ b/Bullet6/Program.cs
@@ -1,15 +1,25 @@
-using Bullet6.Handlers;
-using Bullet6.Interfaces;
-using Bullet6.Models;
+using Bullet6.Solution1;
+using Bullet6.Solution2;
+using Microsoft.Extensions.DependencyInjection;
+using System;
namespace Bullet6
{
public class Program
{
- static void Main(string[] args)
+ static async Task Main(string[] args)
{
- IEntity[] entites = [new Employee() { Name = "Ilias" }, new Manager() { Name = "Maria" }];
- foreach (var entity in entites) EntityHandler.PrintName(entity);
+ ServiceCollection services = new ServiceCollection();
+ services.AddSingleton();
+ services.AddSingleton();
+ var serviceProvider = services.BuildServiceProvider();
+
+ List flows = new List()
+ {
+ serviceProvider.GetRequiredService(),
+ serviceProvider.GetRequiredService()
+ };
+ foreach (var flow in flows) await flow.Start();
}
}
}
diff --git a/Bullet6/Solution1/ISolution1Service.cs b/Bullet6/Solution1/ISolution1Service.cs
new file mode 100644
index 0000000..7645d86
--- /dev/null
+++ b/Bullet6/Solution1/ISolution1Service.cs
@@ -0,0 +1,7 @@
+namespace Bullet6.Solution1
+{
+ public interface ISolution1Service : IFlow
+ {
+
+ }
+}
diff --git a/Bullet6/Models/Employee.cs b/Bullet6/Solution1/Models/Employee.cs
similarity index 62%
rename from Bullet6/Models/Employee.cs
rename to Bullet6/Solution1/Models/Employee.cs
index e56cf07..3ccdf8a 100644
--- a/Bullet6/Models/Employee.cs
+++ b/Bullet6/Solution1/Models/Employee.cs
@@ -1,6 +1,4 @@
-using Bullet6.Interfaces;
-
-namespace Bullet6.Models
+namespace Bullet6.Solution1.Models
{
public class Employee : IEntity
{
diff --git a/Bullet6/Handlers/EntityHandler.cs b/Bullet6/Solution1/Models/EntityHandler.cs
similarity index 71%
rename from Bullet6/Handlers/EntityHandler.cs
rename to Bullet6/Solution1/Models/EntityHandler.cs
index 202b75c..c0b74b2 100644
--- a/Bullet6/Handlers/EntityHandler.cs
+++ b/Bullet6/Solution1/Models/EntityHandler.cs
@@ -1,6 +1,4 @@
-using Bullet6.Interfaces;
-
-namespace Bullet6.Handlers
+namespace Bullet6.Solution1.Models
{
public static class EntityHandler
{
diff --git a/Bullet6/Interfaces/IEntity.cs b/Bullet6/Solution1/Models/IEntity.cs
similarity index 67%
rename from Bullet6/Interfaces/IEntity.cs
rename to Bullet6/Solution1/Models/IEntity.cs
index acc0367..e1327a7 100644
--- a/Bullet6/Interfaces/IEntity.cs
+++ b/Bullet6/Solution1/Models/IEntity.cs
@@ -1,4 +1,4 @@
-namespace Bullet6.Interfaces
+namespace Bullet6.Solution1.Models
{
public interface IEntity
{
diff --git a/Bullet6/Models/Manager.cs b/Bullet6/Solution1/Models/Manager.cs
similarity index 62%
rename from Bullet6/Models/Manager.cs
rename to Bullet6/Solution1/Models/Manager.cs
index e50f482..13445c3 100644
--- a/Bullet6/Models/Manager.cs
+++ b/Bullet6/Solution1/Models/Manager.cs
@@ -1,6 +1,4 @@
-using Bullet6.Interfaces;
-
-namespace Bullet6.Models
+namespace Bullet6.Solution1.Models
{
public class Manager : IEntity
{
diff --git a/Bullet6/Solution1/Solution1Service.cs b/Bullet6/Solution1/Solution1Service.cs
new file mode 100644
index 0000000..a3b86ca
--- /dev/null
+++ b/Bullet6/Solution1/Solution1Service.cs
@@ -0,0 +1,16 @@
+using Bullet6.Solution1.Models;
+
+namespace Bullet6.Solution1
+{
+ public class Solution1Service : ISolution1Service
+ {
+ public Task Start()
+ {
+ Console.WriteLine($"{nameof(Solution1Service)} starting");
+ IEntity[] entites = [new Employee() { Name = "Ilias" }, new Manager() { Name = "Maria" }];
+ foreach (var entity in entites) EntityHandler.PrintName(entity);
+ Console.WriteLine($"{nameof(Solution1Service)} ended");
+ return Task.CompletedTask;
+ }
+ }
+}
diff --git a/Bullet6/Solution2/ISolution2Service.cs b/Bullet6/Solution2/ISolution2Service.cs
new file mode 100644
index 0000000..3fe3d10
--- /dev/null
+++ b/Bullet6/Solution2/ISolution2Service.cs
@@ -0,0 +1,7 @@
+namespace Bullet6.Solution2
+{
+ public interface ISolution2Service : IFlow
+ {
+
+ }
+}
diff --git a/Bullet6/Solution2/Models/Employee.cs b/Bullet6/Solution2/Models/Employee.cs
new file mode 100644
index 0000000..d1edb3f
--- /dev/null
+++ b/Bullet6/Solution2/Models/Employee.cs
@@ -0,0 +1,10 @@
+namespace Bullet6.Solution2.Models
+{
+ public class Employee : Entity
+ {
+ protected override void PrintInternal()
+ {
+ // print the rest possible fields
+ }
+ }
+}
diff --git a/Bullet6/Solution2/Models/Entity.cs b/Bullet6/Solution2/Models/Entity.cs
new file mode 100644
index 0000000..289344d
--- /dev/null
+++ b/Bullet6/Solution2/Models/Entity.cs
@@ -0,0 +1,14 @@
+namespace Bullet6.Solution2.Models
+{
+ public abstract class Entity
+ {
+ public string Name { get; set; }
+ protected abstract void PrintInternal();
+
+ public void PrintName()
+ {
+ Console.WriteLine(this.Name);
+ this.PrintInternal();
+ }
+ }
+}
diff --git a/Bullet6/Solution2/Models/Manager.cs b/Bullet6/Solution2/Models/Manager.cs
new file mode 100644
index 0000000..45cf319
--- /dev/null
+++ b/Bullet6/Solution2/Models/Manager.cs
@@ -0,0 +1,10 @@
+namespace Bullet6.Solution2.Models
+{
+ public class Manager : Entity
+ {
+ protected override void PrintInternal()
+ {
+ // print the rest possible fields
+ }
+ }
+}
diff --git a/Bullet6/Solution2/Solution2Service.cs b/Bullet6/Solution2/Solution2Service.cs
new file mode 100644
index 0000000..9a58bb9
--- /dev/null
+++ b/Bullet6/Solution2/Solution2Service.cs
@@ -0,0 +1,16 @@
+using Bullet6.Solution2.Models;
+
+namespace Bullet6.Solution2
+{
+ public class Solution2Service : ISolution2Service
+ {
+ public Task Start()
+ {
+ Console.WriteLine($"{nameof(Solution2Service)} starting");
+ Entity[] entites = [new Employee() { Name = "Ilias" }, new Manager() { Name = "Maria" }];
+ foreach (var entity in entites) entity.PrintName();
+ Console.WriteLine($"{nameof(Solution2Service)} ended");
+ return Task.CompletedTask;
+ }
+ }
+}