Wednesday, July 4, 2018

Gathering context information for logging

When you write messages to your logs, sometimes it may be useful to add context information. For example, if you write information about some error, you could also include input data in some form, to be able to reproduce the problem easily. Here I'll show how to gather this additional information.

Monday, March 12, 2018

Adding documentation into ASP.NET Web API

When you provide Web API, there is a question, how to inform a user about all its abilities, about the syntax of requests, etc. Usually, you should create some available Web page, where you discuss these topics. But wouldn't it be great, if the Web API itself provided access to the documentation?

Friday, February 9, 2018

Handling JSON errors in OWIN Web application

Somу time ago I wrote an article, where I discuss how to find typos and usage of obsolete properties in JSON body of a request. The described technique required providing a handler of Error event of the JsonSerializerSettings object. The problem is that this object is shared across all requests to your application, but we need separate handling for each request. In this short article, I'll describe how to do it.

Wednesday, December 27, 2017

Finding typos and usage of obsolete properties in JSON

JSON format is very widespread now. Many Web APIs return their results in this format. Also, many APIs accept incoming requests in the same format. Structure of incoming JSON request can be very complex. It is not uncommon to make a typo in such a document. In this article I'd like to discuss, how can we detect these typos and inform users about them in a friendly form.

Saturday, November 18, 2017

Simple parallelizable algorithm for approximate pattern matching

In this article, I'd like to show a simple algorithm for approximate pattern matching. This term generally means that you want to find all places in a big string (text) where a short string (pattern) resides in it. In this form, it defines exact pattern matching. But in our case, we will allow some "errors" (places where the symbol in the text is not equal to the symbol in the pattern). We just want to limit the number of such errors. This is why it is called approximate pattern matching.

Friday, September 15, 2017

Complex deserialization of objects from JSON

Sometimes we need to deserialize JSON into an object model. Here, I'll explain deserialization of objects belonging to a class hierarchy with a support of different formats using Newtonsoft Json.Net library.

Thursday, September 7, 2017

Deferred sorting of collections

Recently I faced a problem of storing sorting information for later use. Sorting is easy if you already have a collection to sort. Just use LINQ extension methods. But what if you don't have the collection yet? What if you'll get the collection later, but you need to store sorting rules now? Here I'll tell you, how it can be done.