X

C#

Fallback logger for Windows 10 IoT Core

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.

Why Azure REST API-s and how to prepare for using them?

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.

Null propagating operator in C#

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.

C#: Expression-bodied members

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#.

Auto-property initializers 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.

Using OneNote API to count degustated beers

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.

Microsoft .NET: Architecting Applications for the Enterprise

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…)

Using Microsoft Solver Foundation to solve linear programming tasks

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.

How to make NLog create separate log per service thread

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.

Generating radial indicator images using C#

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.