Compare commits

..

No commits in common. "main" and "unit-tests" have entirely different histories.

14 changed files with 16 additions and 108 deletions

View File

@ -7,8 +7,4 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
</ItemGroup>
</Project>

View File

@ -1,4 +1,6 @@
namespace Bullet6.Solution1.Models
using Bullet6.Interfaces;
namespace Bullet6.Handlers
{
public static class EntityHandler
{

View File

@ -1,4 +0,0 @@
public interface IFlow
{
Task Start();
}

View File

@ -1,4 +1,4 @@
namespace Bullet6.Solution1.Models
namespace Bullet6.Interfaces
{
public interface IEntity
{

View File

@ -1,4 +1,6 @@
namespace Bullet6.Solution1.Models
using Bullet6.Interfaces;
namespace Bullet6.Models
{
public class Employee : IEntity
{

View File

@ -1,4 +1,6 @@
namespace Bullet6.Solution1.Models
using Bullet6.Interfaces;
namespace Bullet6.Models
{
public class Manager : IEntity
{

View File

@ -1,25 +1,15 @@
using Bullet6.Solution1;
using Bullet6.Solution2;
using Microsoft.Extensions.DependencyInjection;
using System;
using Bullet6.Handlers;
using Bullet6.Interfaces;
using Bullet6.Models;
namespace Bullet6
{
public class Program
{
static async Task Main(string[] args)
static void Main(string[] args)
{
ServiceCollection services = new ServiceCollection();
services.AddSingleton<ISolution1Service, Solution1Service>();
services.AddSingleton<ISolution2Service, Solution2Service>();
var serviceProvider = services.BuildServiceProvider();
List<IFlow> flows = new List<IFlow>()
{
serviceProvider.GetRequiredService<ISolution1Service>(),
serviceProvider.GetRequiredService<ISolution2Service>()
};
foreach (var flow in flows) await flow.Start();
IEntity[] entites = [new Employee() { Name = "Ilias" }, new Manager() { Name = "Maria" }];
foreach (var entity in entites) EntityHandler.PrintName(entity);
}
}
}

View File

@ -1,7 +0,0 @@
namespace Bullet6.Solution1
{
public interface ISolution1Service : IFlow
{
}
}

View File

@ -1,16 +0,0 @@
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;
}
}
}

View File

@ -1,7 +0,0 @@
namespace Bullet6.Solution2
{
public interface ISolution2Service : IFlow
{
}
}

View File

@ -1,10 +0,0 @@
namespace Bullet6.Solution2.Models
{
public class Employee : Entity
{
protected override void PrintInternal()
{
// print the rest possible fields
}
}
}

View File

@ -1,14 +0,0 @@
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();
}
}
}

View File

@ -1,10 +0,0 @@
namespace Bullet6.Solution2.Models
{
public class Manager : Entity
{
protected override void PrintInternal()
{
// print the rest possible fields
}
}
}

View File

@ -1,16 +0,0 @@
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;
}
}
}