erweiterung
This commit is contained in:
10
BeispielInterface2/BeispielInterface2.csproj
Normal file
10
BeispielInterface2/BeispielInterface2.csproj
Normal 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>
|
||||
19
BeispielInterface2/DataBaseLogger.cs
Normal file
19
BeispielInterface2/DataBaseLogger.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
BeispielInterface2/FileLogger.cs
Normal file
18
BeispielInterface2/FileLogger.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
BeispielInterface2/ILogger.cs
Normal file
16
BeispielInterface2/ILogger.cs
Normal 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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
18
BeispielInterface2/Program.cs
Normal file
18
BeispielInterface2/Program.cs
Normal 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....");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user