Schlagwort: C#

  • Create C# SMTP Server

    It took a while to find a library which provides a SMTP server. There are a lot of SMTP clients out there, but the number of SMTP servers seems very limited. Finally, I found a library SmtpServer with an SMTP server and several hooks to extend the functionality. Open port 25 The documentation is straightforward…

  • Pre-Compiler Directives That Make Sense

    The [last blog article](/posts/sonar_code_duplicates/) was dealing with the same linked file in different projects. A reason could be, that some code needs to be compiled with different frameworks. In my case, I had to compile business logic with Microsoft CSOM for SharePoint 2016 and Microsoft CSOM for SharePoint Online. The API is more or less…

  • Dynamically create a generic using reflection

    A long time ago I created a class which helps create a sut for unit testing. This class is generic and has the type of the sut as a generic parameter. Details see ContextFor<> zum Testen des SUT. Now, I was trying to use the `ContextFor<T>` in a data-driven test which passes the type as…

  • ModeDetector vs. Precompiler Directives

    Disclaimer: This solution does not apply to multi-framework targeting. The problem Regularly, I do a lot of refactoring, which means renaming classes and methods. Tools help a lot to rename dependencies and all dependent code. But sometimes, tools cannot determine the correct refactoring for commented-out code. But why care about commented-out code? Because code, which…

  • ContextFor<> zum Testen des SUT

    In meinen Projekte der letzten Jahren ist mit der Zeit eine Hilfsklasse fürs Testen entstanden. Das Problem war das Erstellen des SUT mittels Konstruktor, welcher bei Dependency Injection entsprechend viele Paramter hat oder haben kann. Hier ein Beispiel mit „nur“ 5 Konstruktor Parameter. Dadurch ist Builder entstanden, welcher für jeden Konstruktor Parameter des SUT ein…

  • Dictionary ohne KeyNotFound-Exception

    Derzeit arbeite ich mit dem DevExpress DataGrid für WPF und erstelle die Spalten dynamisch, auf der Basis des Datenbankmappings. Dabei greifen die Daten auf normale Properties, aber auch Felder in einem Dictionary zu. Problem: Nicht jedes Feld aus dem Mapping z.B. „title“ hat auch in dem Dictionary einen entsprechenden Schlüssel. Das DataGrid, bzw. das Binding…

  • Refactoring I – Die Endlosschleife

    Refactoring I – Die Endlosschleife

    Das Refactoring von Code ist laut Wikipedia eine Umstrukturierung von Codes ohne eine funktionale Veränderungen der Software aus Anwendersicht. Es werden nicht-funktionale Anforderungen wie Wartbarkeit, Lesbarkeit, Erweiterbarkeit und weitere *-keiten verbessert. Refactoring kann beispielsweise durch Implementierung eines Plugin Mechanismus stattfinden. Das System wird aber im Rahmen des Refactorings nicht erweitert, sondern allenfalls bestehende Komponenten auf…