Custom Web Api Json Converter For A Single Property

Tuesday, September 23, 2014

The web is well documented regarding usage of a custom Json Converter. Basically the idea is to inherit from JsonConvert, explore the current serialized type and use your own custom behavior when serializing. The custom Json Convert can be used explicitly by calling Json.Convert or implicitly by registering in Application_Start. Explicit: Implicit: The implicit registration will serialize every object that contains the specified type (DateTime? in our example) using the MyJsonDateTimeConverter Converter. The explicit usage will only affect the current serialized value. The other case Both technics won't work in the following case; I need the converter to work only on a specified property, but I cannot...
tags: , , ,
no comments

Working around FacebookSdk.net Permissions BUG FacebookAuthorize attribute

Saturday, June 14, 2014

“Over the past several months Facebook made changes to their application development APIs that were incompatible with the MVC Facebook support.” says N. Taylor Mullen, a developer for the facebooksdk.net team in his latest blog post So it seems the latest sdk version (6.6.0.0) is incompatible with the current Facebook API hence some features won’t work. One basic feature mentioned in the tutorial for using the SDK is the FacebookAuthorize attribute which allows asking permissions for the Facebook app. Could not convert string to integer: installed. Path 'data.permission', line 1, position 34. It seems people are aware of the problem but still haven't...
tags: , , ,
4 comments

Be careful what you LINQ for: Mixing LINQ to SQL with LINQ to Entities

Wednesday, May 28, 2014

An exception I encountered today, led me to pay more attention about the differences between LINQ to SQL and LINQ to Entities. Here is what I learned; Imagine your in a school, and the students council has announced the winners in the school's yearly programming competition. We have a bunch of students, and the winners names. Let's get all the winning student, that's easy: using (var db = new School()) { //Create students list var students = new List<Student> { new Student { ID =...
no comments

WPF – Binding ListBox SelectedItems – Attached Property VS Style

Friday, May 2, 2014

It seems List Box doesn’t support SelectedItems property Binding. Well since my application does support multiple items selection, I went looking for a solution. What I found was the following: Support Multiple Selection Using Style Add the following style in the listbox’s XAML: <ListBox.ItemContainerStyle>                               <Style TargetType="{x:Type ListBoxItem}">                                   <Setter Property="IsSelected" Value="{Binding Mode=TwoWay, Path=IsSelected}"/>                               </Style>                           </ListBox.ItemContainerStyle> Add support for the styling in the view model: We have to support the style by wrapping the original AnimalType class. publicclassAnimalTypeForView       {           publicbool IsSelected { get; set; }           publicAnimalType Type { get; set; }       }       publicList<AnimalType> AnimalTypes       {           get { return AnimalTypes; }           set           {               _AnimalTypes =value;               NotifyOfPropertyChange(() => _AnimalTypes);           }       } I don’t like that, since it adds noise and mess to the view model code and it...
6 comments