Commit 47defdf4 authored by Uwe Wienkop's avatar Uwe Wienkop

2020-06-16a

parent 9dea08d0
using System;
using System.Collections.Generic;
namespace _08_DelegateAnwendungen
{
......@@ -9,14 +10,30 @@ namespace _08_DelegateAnwendungen
static T[] ApplyAll<T>(MeineFkt<T> fkt, params T[] werte)
{
T[] erg = new T[werte.Length];
Console.Write("APPLY ALL: ");
for (int i = 0; i < werte.Length; i++)
{
erg[i] = fkt(werte[i]);
Console.Write (erg[i]); Console.Write(" ");
Console.Write ($"{erg[i]} ");
}
Console.WriteLine();
return erg;
}
static T[] Select<T>(Predicate<T> filter, params T[] werte)
{
Console.Write("SELECT: ");
List<T> erg = new List<T>();
foreach (var item in werte)
{
if (filter(item))
{
erg.Add(item);
Console.Write($"{item} ");
}
}
Console.WriteLine();
return erg.ToArray();
}
static int Quadrieren(int x) => x * x;
static void Main(string[] args)
......@@ -29,6 +46,10 @@ namespace _08_DelegateAnwendungen
string[] namen = { "Anton", "Berta", "Claudia", "Emil", "Dieter" };
ApplyAll(x => x.ToUpper(), namen);
Console.WriteLine("----------");
Select (x => x.Contains("E"), ApplyAll(x => x.ToUpper(), namen));
Console.WriteLine("----------");
Select(x => x > 100, ApplyAll(x => x * 2, 10, 30, 40, 50, 60, 70, 80, 100));
}
}
}
......@@ -10,3 +10,4 @@ C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\De
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.dll
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.pdb
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.genruntimeconfig.cache
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08 DelegateAnwendungen\obj\Debug\netcoreapp3.1\08 DelegateAnwendungen.csprojAssemblyReference.cache
......@@ -10,3 +10,4 @@ C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08Button\obj\Debug\netcoreapp
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08Button\obj\Debug\netcoreapp3.1\08Button.dll
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08Button\obj\Debug\netcoreapp3.1\08Button.pdb
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08Button\obj\Debug\netcoreapp3.1\08Button.genruntimeconfig.cache
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\08Button\obj\Debug\netcoreapp3.1\08Button.csprojAssemblyReference.cache
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_09_UebgMailVerteilung</RootNamespace>
</PropertyGroup>
</Project>
using System;
namespace _09_UebgMailVerteilung
{
public delegate void Callback(string s);
class MailServer
{
/* ToDo: Delegate/Event anlegen */
verteiler;
public void Senden(string s)
{
/* ToDo: Aufruf des verteilers */
}
}
// Bis hierher: Code der Firma A
// Ab hier: Code der Firma B
class Program
{
static void Main(string[] argv)
{
MailServer mb = new MailServer();
/* ToDos:
* Geben Sie mindestens zwei geeignete CallBack-Methoden an
* Rufen Sie den Mail-Verteiler mit Beispieltexten auf
* Verwenden Sie bei den CallBack-Methoden auch Methoden aus anderen Klassen als Program
* Nehmen Sie eine Rückruf-Methode wieder aus dem Mailverteiler heraus
* Geben Sie noch eine Nachricht aus
*/
mb.verteiler += /* .... */; // Einspeichern/Registrieren der Objekt+Methodenreferenz
mb.Senden("Geheime Nachricht"); // wird an alle registrierten Empfänger gesendet
}
}
}
{
"format": 1,
"restore": {
"C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\09 UebgDiMailVerteilung.csproj": {}
},
"projects": {
"C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\09 UebgDiMailVerteilung.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\09 UebgDiMailVerteilung.csproj",
"projectName": "09 UebgDiMailVerteilung",
"projectPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\09 UebgDiMailVerteilung.csproj",
"packagesPath": "C:\\Users\\wienkop\\.nuget\\packages\\",
"outputPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\wienkop\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.301\\RuntimeIdentifierGraph.json"
}
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\wienkop\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.6.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
{
"format": 1,
"restore": {
"C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\09 UebgMailVerteilung.csproj": {}
},
"projects": {
"C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\09 UebgMailVerteilung.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\09 UebgMailVerteilung.csproj",
"projectName": "09 UebgMailVerteilung",
"projectPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\09 UebgMailVerteilung.csproj",
"packagesPath": "C:\\Users\\wienkop\\.nuget\\packages\\",
"outputPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\wienkop\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.301\\RuntimeIdentifierGraph.json"
}
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\wienkop\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.6.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("09 UebgDiMailVerteilung")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("09 UebgDiMailVerteilung")]
[assembly: System.Reflection.AssemblyTitleAttribute("09 UebgDiMailVerteilung")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Von der MSBuild WriteCodeFragment-Klasse generiert.
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("09 UebgMailVerteilung")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("09 UebgMailVerteilung")]
[assembly: System.Reflection.AssemblyTitleAttribute("09 UebgMailVerteilung")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Von der MSBuild WriteCodeFragment-Klasse generiert.
{
"version": 3,
"targets": {
".NETCoreApp,Version=v3.1": {}
},
"libraries": {},
"projectFileDependencyGroups": {
".NETCoreApp,Version=v3.1": []
},
"packageFolders": {
"C:\\Users\\wienkop\\.nuget\\packages\\": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\09 UebgDiMailVerteilung.csproj",
"projectName": "09 UebgDiMailVerteilung",
"projectPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\09 UebgDiMailVerteilung.csproj",
"packagesPath": "C:\\Users\\wienkop\\.nuget\\packages\\",
"outputPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\wienkop\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.301\\RuntimeIdentifierGraph.json"
}
}
}
}
\ No newline at end of file
{
"version": 2,
"dgSpecHash": "Wu5ykFPqrdgYbk8owYPiKQBtuFhVkP4RV9q2ubf0SvqYzm4vgisgtwKe4zfKjguQLKBdkceTqND/8tU8NbBB3w==",
"success": true,
"projectFilePath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09 UebgMailVerteilung\\09 UebgDiMailVerteilung.csproj",
"expectedPackageFiles": [],
"logs": []
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
namespace MailServer
{
class Mail
{
public string Header { get; set; }
public string Body { get; set; }
public Mail(string header, string body) { Header = header;Body = body; }
public override string ToString() => $"Header: {Header}\nBody: {Body}";
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace MailServer
{
delegate void SpamCheckerDelegate(Mail mail);
class MailServer
{
// Regeln Mail-->bool, Mail->Mail
public event SpamCheckerDelegate spamchecker;
public void Send(Mail mail)
{
// Mails auf SPAM prüfen
// Falls SPAM: Mail = Modifizierte Mail
spamchecker?.Invoke(mail);
Console.WriteLine(mail);
}
}
}
using System;
namespace _09TestProjekt
namespace MailServer
{
class Program
{
static void mySpamChecker(Mail m)
{
if (m.Body.Contains("Supersonderangebot"))
m.Header = "[SPAM] " + m.Header;
}
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
MailServer ms = new MailServer();
ms.spamchecker += mySpamChecker;
ms.Send(new Mail("BestBuy Newsletter", "Hier erhalten Sie unser Supersonderangebot"));
}
}
}
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"09 MailServer/1.0.0": {
"runtime": {
"09 MailServer.dll": {}
}
}
}
},
"libraries": {
"09 MailServer/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
\ No newline at end of file
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\wienkop\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\wienkop\\.nuget\\packages"
]
}
}
\ No newline at end of file
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.1.0"
}
}
}
\ No newline at end of file
{
"format": 1,
"restore": {
"C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09TestProjekt\\09 MailServer.csproj": {}
},
"projects": {
"C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09TestProjekt\\09 MailServer.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09TestProjekt\\09 MailServer.csproj",
"projectName": "09 MailServer",
"projectPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09TestProjekt\\09 MailServer.csproj",
"packagesPath": "C:\\Users\\wienkop\\.nuget\\packages\\",
"outputPath": "C:\\Users\\wienkop\\source\\repos\\prog2-ss2020-wienkop\\09TestProjekt\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\wienkop\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.301\\RuntimeIdentifierGraph.json"
}
}
}
}
}
\ No newline at end of file