Update: In the 7.x release of Json.NET, a DictionaryKeyResolver was added that might be able to fix this problem too. I haven’t used it yet, so I can’t really say, but you might want to check it out. JSON.NET is a great tool and it already handles Dictionaries well, unless your keys are classes (as opposed to structs). Say you have the following class you want to serialize: public class DataPoints { public IDictionary<DataPointKey, int> Values { get; set; }

The situation is simple: we need to send messages to another system the developers of the other system need documentation on the layout of these messages this is a company-specific protocol (no JSON or anything standard, because we’re talking to old Fortran machines here) naturally, the documentation is made in Word files Taking an example from a session I saw at ngEurope, I decided we might be better off auto-generating this documentation. Keeping Word files in sync with the evolving

I’m currently developing a Windows service application that receives data from multiple sources. It isn’t a highly concurrent application, but the incoming messages are come fairly fast after one another. Incoming messages enter the system via WCF and that part is multithreaded. But these messages must be handled sequentially. What’s more, certain pieces of our application must run at regular intervals. We can experience problems if component A is running and changing objects in memory, and component B is triggered

Almost all articles on WPF and validation focus first on ValidationRules, and then continue telling you why IDataErrorInfo is better. A few go on and show you how to combine IDataErrorInfo with DataAnnotations. While these last two are definitely good options, they’re a little heavy for a very simple application. In my case: call a server, show the data (about 20 textboxes), send back to the server. Nothing fancy, I’m even databinding to my datacontract (gasp!), although I’m sending back

JSON.NET can handle serializing and deserializing private fields, but you have to tell it to do so. In the past, you had to set the DefaultMembersSearchFlags property of the ContractResolver of your settings. But this property is now marked obsolete. The documentation/Intellisense tells you to override GetSerializableMembers instead. But I’ve found there’s just one extra step involved. First thing to do is to create your own class that inherits from DefaultContractResolver and override the GetSerializableMembers method: protected override List<MemberInfo> GetSerializableMembers(Type

In my previous post, I described how to authenticate your Windows Phone app to Twitter, without using TweetSharp. Now that we’re set up, posting a status to Twitter is fairly easy (see below, after code for posting photo). But posting a photo is a little more challenging. Once again, we’ll be using the Hammock library by Daniel Crenna.First, we need to set a few things up: var twitterUser = new TwitterUserQuery().Get(); _credentials = new OAuthCredentials { Type = OAuthType.ProtectedResource, SignatureMethod

If you’re developing an application that needs to use Twitter, you’ll most likely have to authenticate in order to post tweets. If you’re using C#, you can use TweetSharp. However, I found it doesn’t really work for Windows Phone, in particular because the GetRequestToken method is missing. This is not to say the work Daniel Crenna is bad, far from it. But for a Windows Phone app I’m developing I needed to authenticate with Twitter. And finally, TweetSharp is no

Ouch, pained my brain over this one for the last half hour or so, but finally found the solution. I had a call similar to: repository .Stub(x => x.TryGet(<Specification>.Matches(y => y.Something), Arg<Customer>.Out(customerToReturn).Dummy)) .Return(true); Because my first argument had a fairly large Matches call (it’s simplified here), I refactored it to: var specification = Arg<Specification>.Matches(y => y.Something); repository .Stub(x => x.TryGet(specification, out Arg<Customer>.Out(customerToReturn).Dummy)) .Return(true); Ah, much more readable! Only, it didn’t work. The exception I got was: Use Arg<T> ONLY within

I just go my AppHarbor build to work, and can definitely recommend it if you have a project of your own. It’s a builder server and hosting in one. I switched to Mercurial for this, but it will work with Git also. I just wanted to be able to tell the girls in the club that I use Mercurial. When I push my changes to BitBucket, AppHarbor will pull them in (it also works with GitHub, Codeplex,…), build my solution,

On two projects I have worked on, I’ve seen a lot of this: public void DoSomething() { try { // actually do something here } catch (Exception ex) { throw new Exception(“Unable to do something”, ex); } } I’ve seen this in various differing styles: not including the original exception in the newly thrown one (ouch!)* having a custom Exception type, indicating where in the code/assemblies the exception happened.Reasons seem to be a desire to easily see where the exception