Peter Morlion logo

A generic JsonConverter for Dictionaries and JSON.NET

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 […]

Comparing a local file with a workspace file with C# and TFS

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 […]

Synchronizing multithreaded incoming messages and unit testing

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 […]

Collecting all errors of ValidationRules in WPF

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 […]

Serializing private fields with JSON.NET and GetSerializableMembers

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 […]

Posting a photo to Twitter in Windows Phone

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 […]

Connecting a Windows Phone app to Twitter

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 […]

RhinoMocks and Use Arg T only within a mock method call while recording exception

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 => […]

AppHarbor, Mercurial (or Git), awesomeness

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 […]

Exceptions everywhere

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 […]