erweiterung

This commit is contained in:
2023-03-23 15:55:13 +01:00
parent 33e49f846c
commit 09c8eab938
39 changed files with 1167 additions and 1 deletions

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
namespace BeispielInterface2
{
internal class DataBaseLogger : ILogger
{
public void LogData(string text)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine($"Der Text \"{text}\" wird in die Datenbank gespeicher");
Console.ForegroundColor = ConsoleColor.Gray;
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeispielInterface2
{
internal class FileLogger : ILogger
{
public void LogData(string text)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"Der Text \"{text}\" wird in der Datei gespeicher");
Console.ForegroundColor = ConsoleColor.Gray;
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeispielInterface2
{
interface ILogger
{
public void LogData(string text)
{
}
}
}

View File

@@ -0,0 +1,18 @@
namespace BeispielInterface2
{
internal class Program
{
static void Main(string[] args)
{
MethodeProgrammablauf(new FileLogger());
MethodeProgrammablauf(new DataBaseLogger());
}
static void MethodeProgrammablauf(ILogger logger)
{
Console.WriteLine("Die Methode macht aufregende Ding....");
Console.WriteLine("Zwischendurch muss Sie Dinge Loggen.");
logger.LogData("Wichtige Infos");
Console.WriteLine("Und weitere aufgende Dinge Passieren....");
}
}
}