diff --git a/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022.csproj b/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022.csproj
index 24285f6..a8390de 100644
--- a/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022.csproj
+++ b/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022.csproj
@@ -8,6 +8,7 @@
+
diff --git a/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/Program.cs b/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/Program.cs
index f3ecb9e..877637e 100644
--- a/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/Program.cs
+++ b/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/Program.cs
@@ -12,6 +12,7 @@ namespace OOP_Opdracht_CSharp_Alfa_2022
Opdracht2();
Opdracht3();
Opdracht3c();
+ Opdracht4();
}
static void Opdracht2()
{
@@ -43,7 +44,6 @@ namespace OOP_Opdracht_CSharp_Alfa_2022
Console.WriteLine($"Trying to fetch KeyValue with invalid id 5 {publisher.find(7)}"); // Attempt to find invalid record and output to Console
}
-
static void Opdracht3c()
{
Publisher publisher = new Publisher("publisher"); // Init publisher class instance
@@ -74,5 +74,8 @@ namespace OOP_Opdracht_CSharp_Alfa_2022
}
}
}
+ public static void Opdracht4(){
+ Config config = Config.getInstance();
+ }
}
}
diff --git a/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/classes/Config.cs b/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/classes/Config.cs
new file mode 100644
index 0000000..daa52ee
--- /dev/null
+++ b/OOP-Opdracht-CSharp-Alfa-2022/OOP-Opdracht-CSharp-Alfa-2022/classes/Config.cs
@@ -0,0 +1,47 @@
+using System.Collections.Generic;
+using System.Collections;
+using System.Linq;
+using System.Configuration;
+using System;
+
+
+class Config{
+
+ private static Config instance = null;
+ private Dictionary contents;
+ private Config(){
+ contents = GetSettings();
+ }
+ public static Config getInstance(){
+ if ( instance == null ) instance = new Config();
+ return instance;
+ }
+ Dictionary GetSettings()
+ {
+ Dictionary settings = new Dictionary();
+ try
+ {
+ var appSettings = ConfigurationManager.AppSettings;
+ if (appSettings.Count == 0)
+ {
+ Console.WriteLine("AppSettings is empty.");
+ }
+ else
+ {
+ var keys = appSettings.AllKeys;
+ foreach(string key in keys){
+ String value = appSettings.GetValues(key).GetValue(0).ToString();
+ #if DEBUG
+ Console.WriteLine($"Debug: key {key} has value {value}");
+ #endif
+ settings.Add(key,value);
+ }
+ }
+ }
+ catch (ConfigurationErrorsException)
+ {
+ Console.WriteLine("Error reading app settings");
+ }
+ return settings;
+ }
+}
\ No newline at end of file