Here is a simple implementation of the shared Logger (based on NLog) that can be easily included into any solution with minimum configuration.
I’d like to introduce a library for accessing app settings in the App.config and Web.config. Unlike standard
ConfigurationManager, ConfigEx additionally allows reading configs of other assemblies used in the project. Moreover, it is strongly typed, has a mechanism of settings overriding and allows apply automatic conversion of values.
Have you ever had a task to read and deserialize a large XML file? Like 500 MB, that is impossible just to read to the end and parse. I’ve faced such problem having an XML that looks like the following:
<?xml version="1.0" encoding="UTF-8"?> <record id="0" Text="Some text for record 0" /> <record id="1" Text="Some text for record 1" /> <record id="2" Text="Some text for record 2" /> <record id="3" Text="Some text for record 3" /> ... <record id="1000000" Text="Some text for record 1000000" />
Just and interesting note that I’ve found while updating the ConfigEx library: the assembly DLL file in ASP.NET application might be located in place different from what we expect. During runtime it is actually not in the place where application is hosted.
WPF Async Pack is a small library for creating asynchronous WPF applications. It’s not a framework, it was created mainly for the small applications where installing heavy frameworks is just overkill. It doesn’t have any dependencies and contains such the most used classes as AsyncCommand and BaseViewModel.
The library can be installed through the NuGet:
PM> Install-Package WpfAsyncPack
In C# in order to control what code should be executed we can use compilation directives #if, #else, #elif and #endif. For instance, we can compile certain code only in Debug mode and exclude one in Release. #if directive can be used not only to test for symbols DEBUG and RELEASE. We are able to define any symbols. Let’s take a look how to do that and how to use newly defined symbol in the code. For example, we want to add some funny log messages when symbol FUN_MODE is defined.
- First, define a new compilation symbol for the whole project in the project’s properties:
- Then we can check for defined symbol in the code:
#if FUN_MODE logger.Debug("Yahoo! It looks like our app finally works!"); #else logger.Debug("Application started."); #endif
Everything is quite simple. The question is how to achieve the same in XAML code.
Imagine a quite common client-server application where server exposes REST methods and client communicates using HTTP requests. Requests and responses are serialized in JSON format. There might be a problem if you try to send and receive a DTO that contains a collection of interfaces or abstract classes. I will talk about usage of Web API and Newton Json.NET as it’s underlying serialization library.