Fill a dictionary with properties of a class

Following scenario… you need to create a key/value configuration file within a configuration class. Properties are the Keys and their value is the value ;). Values for the properties need to be assigned automaticly when the “configuration file” is loaded, in a way that the class can be extended with new properties and no new code needs to be added.

One of the solutions I found, was to use a Singleton-Pattern with

Dictionary<string, object>

that holds all the property keys and values.

Lets walk this through with a real life example. Nlog is used for logging. At the End you can see the whole class, but first let us go through everything step by step.

First the properties:

public bool ConfigurationSet { get; set; }
public string RemoteIPAddress { get; set; }
public string RemotePort { get; set; }
public string LocalIPAddress { get; set; }
public string LocalPort { get; set; }
public bool TCP { get; set; }
public bool UDP { get; set; }
public bool Multicast { get; set; }
public bool GzipCompression { get; set; }
public string ReceiveBufferSize { get; set; }
public string MaxSegmentSize { get; set; }
public string SocketBufferSize { get; set; }
public string DateMatchGroup { get; set; }
public string TextAfterDateMatch { get; set; }
public string TextBeforeProviderMatchGroup { get; set; }
public string ProviderMatchGroup { get; set; }
public string TextBeforeXMLCallListMatchGroup { get; set; }
public string FullRegex { get; private set; }
public string CallListMatchGroup { get; set; }
public string ConfigurationPath
		return _configurationPath;
	private set => _configurationPath = value;
public string ConfigurationFile
		return _configurationFile;
	private set => _configurationFile = value;
public string ExtractionFileName { get; set; }
public string ExtractionFolder { get; set; }
public string MulticastSendTimeoutInMS { get; set; }

The “ConfigurationSet” Property is not used in the configuration file. It can be used for other parts of the program to find out if the configuration has been loaded and the properties have values.

Then there is the Dictionary as <string, object> and the singleton with the private and static constructor, this is thread-safe!

private static readonly object _locker = new object();
public Dictionary<string, object> ConfigurationItems { get; private set; }
private static readonly ConfigurationHelper _configuration = new ConfigurationHelper();
public static ConfigurationHelper Configuration
		return _configuration;
	private set
			_configuration = value;

private ConfigurationHelper() { }

static ConfigurationHelper() { }

for more information on singletons, see:

The last Members are the Configurationfolder, the configurationfilename and the logger (nlog).

private string _configurationPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Reflection\";
private string _configurationFile = "reflection.config";
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
Posted in C#, PC, programming, Sonstiges, Wissen, Work | Tagged , , , , | Leave a comment

Warum Qualitätssicherung wichtig ist!

In die Qualitätssicherung von Software wird grundsätzlich zu wenig investiert (Projekte sind zu knapp geplant, Budget wird für andere Bereiche aufgebraucht, etc.). Wieso dies ein Fehler ist oder warum gerade in systemkritischen Bereichen der Softwaretest nicht zu kurz kommen darf, zeigt Linux nach der Installation auf bestimmte Thinkpads auf.

Sollte auf einem Thinkpad mit UEFI Bios, Linux installiert oder sogar eine Festplatte mit Linux  eingebaut werden, wird das Notebook irreparable beschädigt.


Posted in Deutsch, Languages, PC, programming, Sonstiges, Testing, Work | Tagged , , , , , | Leave a comment

Nature One 2014

This year again 😉 to the nature one… 20 year anniversary 😉

will be fun, we say,
will be cool we say!

Posted in Events, Music, Spaß | Tagged , , | Leave a comment

User Clean UP

Deleted all users with Zero (0) posts ;), well at least all that I didn’t know.

Posted in administration | Leave a comment

New Flat

This gallery contains 6 photos.

One month ago I moved into a new flat and I’m renovating the living room 😉

More Galleries | Leave a comment

New sound from south africa

Fantastic new sound from south Africa, absolutely must hear 😉

Die Antwoord – Baby’s on fire

Die Antwoord – I Fink U Freeky

Official Youtube Channel:

Official Website:

Itunes Link for the new Album “Ten$ion:$ion/id497643650?ls=1


Update: Here is another one, from the Album $O$

Die Antwoord – Enter the Ninja

Posted in English, Languages, Music, Youtube | Tagged , , , , , , , , , , , , , , | Leave a comment

Fei Fei

Currently listening to one of my favorite djs FeiFei 😉

[soundcloud id=’45421908′]


here is the direct link:

Posted in English, Languages, Music | Tagged , , , , | Leave a comment

Kleine und Große Quadratische Lösungsformel

Allgemeiner quadratische Funktion: $latex ax^2 + bx + c$

Die “große” Lösungsformel: $latex x_{1,2} = \frac{-b\pm\sqrt{b^2-4ac}}{2a}$ wird angewendet wenn $latex a$ ein numerischer Wert größer 1 ist.

zb.: $latex 3x^2+2x+3$ oder $latex 3x^2+2x$

Die “kleine” Lösungsformel: $latex x_{1,2} = -\frac{p}{2}\pm\sqrt{(\frac{p}{2})^2-q}$ wird angewendet wenn $latex a$ den numerischen Wert 1 hat.

zb.: $latex x^2+4x+2$ oder $latex x^2+4x$

weiterführende Informationen können in der Wikipedia nachgeschlagen werden:

Posted in Deutsch, Mathematik, Wissen | Tagged , , , , , , , | Leave a comment

Simple Hello Kitty with C#

How to create a Simple “Hello Kitty” with C# (Console Application)

First we create a “Console-Application-Project” within the Visual C# Express Studio

Create a new console Project within Visual Studio Express C#


The Console Project Name can be anything you like (ex. HelloKitty)

After pressing “ok” the File Program.cs will be opened.

It will look something like this:


With the codeline: System.Console. you can work with the console “window”, display data, read data, etc.

To Display a normal text you use the function “WriteLine”, which writes a line of text. If you want to write just one character, you can use “Write” instead.

System.Console.WriteLine("Hello Kitty");

If you compile the program, the console window will be closed instantaneous, to prevent this behavior, we wait till the user enters at least one character.

This can be achvieved with the functions “ReadKey”, “Read” or “ReadLine”. The difference between those functions is that “ReadKey”, reads exactly one character and displays this character on the console, “Read” reads just the next character and “ReadLine” reads the whole line on the console application.


It should look like this now:

using System;
using System.Text;

namespace HelloKitty
    class Program
        static void Main(string[] args)
            System.Console.WriteLine("Hello Kitty");

After compiling the program, it should open a console window and display the text which has been entered after the  “WriteLine” command:

Hello Kitty

Posted in English, Languages, programming | Tagged , , , , , , , , , | Leave a comment

Mein Blog lebt…

… ab und zu zumindest 😉 *gg*


Posted in Music | Tagged , , | Leave a comment