Last night I was dealing with anonymous types and some IL code to creating and assigning values to instances of anonymous types. I stumbled upon this question: How do I declare a Field with Anonymous Type (C#) – http://stackoverflow.com/questions/964334/how-do-i-declare-a-field-with-anonymous-type-c It didn’t have anything to do with what I was doing but the thing I was … Continue reading »
Filed under C# 101 …
C#, Why params object[] should be forbidden! (v2)
Edit: This post has been rewritten since I first wrote it. I wrote the first edition in frustration and wasn’t to clear on my point. Lets start with a sample. First we have a method accepting an int[], using the params keyword. It just tries to output them. Lets consume it Fine. Just what we … Continue reading »
C#, Parallel deserialization of JSON stored in database
The scenario A while back ago I had to yield entities constructed by deserializing JSON stored in a database. The first solution just opened a simple single result, sequential reader against the database returning a one column result set containing JSON. This was just yield returned after deserialized to the desired entity. Trying to tweak … Continue reading »
C#, Visual Studio 2010, No more Client profile in 5minutes.
I guess I’m not alone being tired of running into the “Client profile” framework version used when creating a Console application in Visual Studio 2010. Don’t know how life is going to be in coming version of Visual Studio, but until then, lets show you a solution that takes no more than 5 minutes. Step … Continue reading »
C#, Generic factory with support for private constructors
Today I got involved in a small question on Twitter on how to create a generic factory creating instances of classes having a private constructor. So I put together a small sample that shows a two solutions: Using Activator (around 22s per 100000) Using compiled lambdas (around 8s per 100000) The example lets you time … Continue reading »
Ensure.That – a simple guard clause project
Yes I know there’s a bunch of these projects out there already and that there’s built in support for using code-contracts in .Net, but even so we found a need for a custom API, hence Ensure.That was created. Also, I think Microsoft’s Code-contracts fails on the part of having to install an add-on to VS2010 … Continue reading »
C# – Building a dynamic method recorder using DynamicObject
Was at an OpenSpace event today in Stockholm. Was really great. Lots of inspiring discussions. Was in a discussion about Ruby/IronRuby and C# where there was this case where a methodcall recorder was built with a few lines in Ruby and that it wasn’t doable that easy in C#. Well, I kind of disagree and … Continue reading »
Json.Net vs ServiceStack.Text
This is going to be a verry short comparision of the two Json-serialization frameworks: Json.Net – http://json.codeplex.com ServiceStack.Text – https://github.com/mythz/ServiceStack.Text I have always used Json.Net when dealing with serialization of entities back and forth to Json, but then I stumbled upon this: “Fastest JSON Serializer for .NET released” – http://www.servicestack.net/mythz_blog/?p=344 Man was I excited, since … Continue reading »