My last post about tuple literals gave brief intorduction to these. This post goes to internals of tuple literals, peeks behind the compiler and shows what happens with tuple literals internally. This post is for developers who are new to tuple literals and want to gain more deep understanding of these.
Working on some threading stuff I stumbled upon some discussions about lock and Monitor. Some say they are different and some say they are the same. I took few minutes of time to make some simple experiments with both of these. This blog post shows what C# compiler does with lock statement. As I had to use also Monitor class I added one example here how to use it instead of lock.
C# 7.1 introduces asynchronous Main method for console applications. It helps us to get rid of some ugly code to await for asynchronous methods. If Main method of console applications is application flow controller that makes multiple calls to asynchronous methods then async Main leads us to much cleaner code. This blog post is my deep dive to async Main.
One of new features of C# 7.0 is support for local functions. Local functions are methods that are defined inside other methods to simplify more complex code and by example to support local recursion. This blog post shows how to use local functions in C# 7.0 and gives some advice in context of technical design of code.
C# 7.0 brings some new features to tuples and with code editors that support these new features we can use tuples with named members instead of names like Item1…ItemN. This blog post goes through practical example that demonstrates how to move on classic method that returns multiple values to new tuples.
We love to use our favorite logging solutions as much as possible but if external storage or external services are involved we cannot guarantee that logging works in crisis situation. This blog post introduces wrapper logger that uses main one to log all the messages and secondary one when main logger fails. Implementation is easy but there’s a good chance that log messages doesn’t get completely lost when main logging service goes down.
When new Microsoft Azure services come they usually have REST API-s available. Of course, there are usually client libraries available too as NuGet packages but usually not for every .NET flavour. Although Microsoft has plans to publish libraries for CoreCLR too it doesn’t happen always fast. Let’s see how REST API-s work and how to prepare for using them.
C# 6.0 introduces language feature called null propagation. It’s about avoiding all this if-else mess in most sanity checks that avoid NullReferenceException.Of course, null checks can be found also from other parts of code that doesn’t necessarily deal with sanity checks. Let’s see how new null propagation feature help us write cleaner code.
New C# introduces expression-bodied members of classes. Instead of property or method that makes some simple calculation we can define expressions and keep our code shorter. Nice thing is – also other .NET languages are able to use these new members. Let’s see what we can do with expression-bodied members in C#.
Automatic properties is good feature in C# as we don’t have to declare variables for property values in our code. Instead we move this responsibility to compiler that automatically generated hidden backing field for property. New C# solves another problem – assigning default values to automatic properties.
I am heavy OneNote user as OneNote is easybut still powerful application to keep important information and organize it the way I like. Not to mention powerful cloud back-end that makes my OneNote notebooks available for me on desktop, tablet and mobile phone. In this posting I will show you some code I use to update the number of degustated beers in beer diary.
Enterprise applications need good architecture to survive ever-changing demands of customers. At same time these systems must be stable, convenient and easy to use which leads us to need of good architecting skills. Some customers need desktop applications while others need web-based and mobile applications. Making good architectural decisions is not easy and this is where brilliant book Microsoft .NET: Architecting Applications for the Enterprise by Dino Esposito and Andrea Saltarello comes in. (more…)
One of soon-to-starts projects uses linear programming for some optimizations. As it is not very familiar topic to me I started looking for examples and tools so I am prepared better when action starts. In this posting I will show you how to solve simple linear programming tasks using Microsoft Solver Foundation – free math package available by DevLabs.
NLog on is popular logging component for .NET applications. I am using it in one project where I built multi-threaded server that is running similar threads with different configuration. As those thread are independent services I needed way how to configure NLog to create different log file for each thread. Here is my solution.
In one of my projects I needed to draw radial indicators for processes measured in percent. Simple images like the one shown on right. I solved the problem by creating images in C# and saving them on server hard disc so if image is once generated then it is returned from disc next time. I am not master of graphics or geometrics but here is the code I wrote.
Excel with its file formats is not the only spreadsheet application that is widely used. There are also users on Linux and Macs and often they are using OpenOffice and other open-source office packages that use ODF instead of OpenXML. In this post I will show you how to read Open Document spreadsheet in C#.
I’m building web application for customer and there is requirement that users must be able to import data in different formats. Today we will support XLSX and ODF as import formats and some other formats are waiting. I wanted to be able to add new importers on the fly so I don’t have to deploy web application again when I add new importer or change some existing one. In this posting I will show you how to build generic importers support to your web application.
It is often good idea to isolate our domain model from consuming applications by using service layer and data transfer objects (DTO) or application specific models. Using DTO-s means that we need two-way mapping between domain classes and DTO-s. In this posting I will show you how to use AutoMapper to build generic base class for your mappers.