Skip to main content

GUID vs LUUID: How to handle GUIDs in MongoDB with C#

LUUID vs GUID

Introduction In this blog post, we will discuss the differences between GUID and LUUID in MongoDB when working with C#. We will explore the default behavior of the MongoDB serializer and provide solutions to ensure compatibility between GUIDs and LUUIDs. Understanding the Issue When a C# GUID is saved in a MongoDB collection, it is […]

Options Pattern in ASP.NET Core

option-pattern

Introduction This post is about the Options Pattern in ASP.NET Core and how to use it to retrieve values from the AppSettings.json file. I will also explain how to inject the options into your classes and provides an example of using the Options Pattern in unit tests. What is the Options Pattern? The Options Pattern […]

How to Improve Testability and Mockability of NServiceBus

nservicebus_logo

Introduction In this blog post, we will address the challenge of testing and mocking the IMessageSession interface when using NServiceBus to send messages. We will explore a solution that involves creating a wrapper class, NServiceBusHelper, which can be injected into the constructor instead of the IMessageSession interface, making it mockable in integration tests. The problem […]

C# – Parse String Hour to TimeSpan or DateTime

timespanformatexception

Converting a String to something else can always be tricky. Especially if that String is about time. The thing is the fact that there are many ways to represent time and that can actually depend on the country you are. 6 PM, 6.00 PM, 06.00, 06:00, 18:00, 18h00, 18H00, they could be all the same. […]

WPF – OpenFileDialog

openfiledialog

This is a simple example to have an OpenFileDialog (a premade view done by Windows to select a file to open) with WPF, filtering on XLSX file: In this case the InitialDirectory will always exist because it is the Desktop of the current user. But you have to know that if the targeted InitialDirectory doesn’t […]

UWP – Theme Overview

UWP Themes Logo

How to get current Windows 10 Theme? In the namespace Windows.UI.ViewManagement, you can Access to the UISettings class. It will allow you to get the Window background and deduce the current theme. How to set the theme when multiple views are open? You must iterate all the views via the CoreApplication. Secondly, you can go […]

C# – JSON serialize and deserialize

Hello Devz, JSON files are really common, we can see them everywhere. They provide a good structure to organize data, are simpler and lighter than XML files, and still human readable. In this simple example, we will show you how to use the Json.NET library (Newtonsoft) from NuGet. It is pretty simple to serialize and […]

C# – Simple email validation regex

Hello Devz, Do you have a web or WPF application that needs email address validation? Regex (regular expression) can help you. This post outlines a simple email validation regex that you can use straight away. What is a regex? A regular expression (regex for short) describes a search pattern using a particular text string. It’s […]