January 2012 Entries

Of Image Exif, PropertyItem and reflection
As documented here on MSDN the PropertyItem object does not have a public constructor. What to do then when you want to add a property to an image, using Image.SetPropertyItem(..) method? This post suggests you create some bank of all property items you want, hold it memory and clone from it. A commenter on that blog suggested using reflection: Get the non-public parameter-less constructor and invoke it. Notable downside for this approach is reliance on internal implementation of the object. True. ......

Posted On Wednesday, January 25, 2012 12:49 PM | Comments (1)

Json serialization – RPC style in MVC
In a previous posting, I discussed replacing the stock MVC serializer used for the JsonResult exposed when you use the controller method Json(..) instead of View. This was all find and dandy. But how – you may wonder – can I call actions that contain complex parameters? Do I need a special binder? Should I write my own? The answer is mostly "no". As Phil Hack blogged, the ASP.NET MVC framework already contains value providers that take care of that for you. All you need to do is ensure that your ......

Posted On Monday, January 16, 2012 6:42 PM | Comments (0)

JSON serialization problems and solution in MVC3
For various reasons you may find that the default JsonResult returned by invoking the controller method such as return Json([data); Is unsuitable for the consumer. The main issue most often encountered is that this method uses the JsonResult which in turn uses the JavaScriptSerializer with no access to the JavaScriptTypeResolver. This means that you can provide that serializer a parameter specifying you own custom type resolver. Other issues, such as maximum recursion depth and maximum length and ......

Posted On Wednesday, January 11, 2012 7:07 PM | Comments (0)