A System.Text.Json converter to serialize/deserialize a JSON node as a string
How to deserialize a part of JSON as a string keeping everything inside as is including the formatting? Or how to merge JSONs together into one having them provided as strings? The article shows an implement of a custom converter for the System.Text.Json
that does described things, and provides additional cases when such converter might be useful.
Convert MongoDB’s UUID to .NET GUID
One of the form how MongoDB represents UUID is BinData
of type 3
or 4
. The post covers how to convert the Legacy UUID (LUUID)
to the .NET GUID
representation.
The issue with the order of newly added entities in Entity Framework Core
Recently I've developed a simple processing application that generates some data in the database. For business logic it was important to understand what entity was created the last on some steps. Since there was no concern about scaling or running several instances simultaneously, it was decided to use the primary key itself, the auto-incremental integer value. I didn't want to rely somehow on date-time or invent something sophisticated.
A custom Json.NET converter
Sometimes, the incoming data in JSON has some custom form that is not supported by the built-in Json.NET converters. In this article, as an educational example, we will implement a custom converter from the UNIX time format in milliseconds to the native .NET class DateTime
.
Dumping any requests in ASP.NET Core 2.0
Once, I was needed to have a simple endpoint in which I can send any request for test purposes. Just a simple web service that eats a request, no matter what HTTP method and route are used.
Fortunately, Microsoft did a great job making ASP.NET Core as flexible as possible, so the solution turned up quite short and simple.
Software versioning in Windows and .NET
My new article about product versions was published. Feel free to read. It explains different kinds of versions, and approaches how to use and implement them. Additionally, my own experience of implementing versioning in my current project.
A shared logger
A simple implementation of the shared Logger based on NLog that can be easily included into any solution with a minimum configuration.
ConfigEx 2.1.0
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 applying automatic conversion of values.
Reading large XML files
Have you ever had a task to read and deserialize a large XML file? Like 500 MB or 2 GB, that is impossible just to read to the end into memory and parse it.
Assembly location in ASP.NET
An interesting note that I've found while updating the ConfigEx library: the assembly DLL file in the ASP.NET application might be located in a place different from what we expect. During runtime, it is actually not in the place where the application is hosted.
WPF Async Pack 1.0
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
.
Compilation directives for controlling XAML content
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
.
The question is how to achieve the same in XAML.
Static extension in WPF XAML and public ResX files
For localization or some other reason you might want to access the static resources in ResX
file from the XAML using Static
extension.
Polymorphic serialization using Json.NET in HttpContent
Imagine a quite common client-server application where the server exposes REST methods and the 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 the usage of Web API and Newtonsoft Json.NET as its underlying serialization library.
Filling model properties using Reflection
In this post I'm going to show how to fill object properties using reflection no matter what types they are.
Setting up system-wide hotkeys
You can see examples of global system-wide hotkeys almost in every application: media players, chats, different tray tools. The application can be minimized or even hidden, but you can control it by pressing hotkeys no matter what is in focus right now.
Unfortunately, .NET Framework doesn't contain convenient classes or methods for setting up global system-wide hotkeys. The only way to achieve this is to use the Windows API functions.
Only one application instance
Sometimes we need to disallow starting multiple instances of our application (for example, it make sense for music players, applications for Windows Tray, etc.). The easiest and, probably, the most proper way is to use Mutex - a synchronization primitive.
Limiting the number of threads
In our project we faced the problem of how to make running some calculations concurrently. We can simply start each calculation in a separate thread but the problem is how to limit the number of threads.
Skype Auto Recorder 1.2
The Skype Auto Recorder version 1.2 was released. It contains important bug fixes and finally can be treated as stable.
The source code is available on GitHub.