Created
August 16, 2013 08:00
-
-
Save andreea-anastasescu/6248117 to your computer and use it in GitHub Desktop.
Custom attribute for generating root element in json serialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Me.WebApi.Mobile | |
{ | |
using System; | |
/// <summary> | |
/// Specifies serilaization options for the classes (models) decorated with this attribute. | |
/// It was introduced to make possible to obtain a 'root' element in the json serilaization of webapi's output used together with <see cref="RootFormatter"/>. | |
/// </summary> | |
[System.AttributeUsage(System.AttributeTargets.Class)] | |
public class JsonCustomRootAttribute:Attribute | |
{ | |
/// <summary> | |
/// Specifies the json root title for any class decorated with this attribute. | |
/// </summary> | |
public string Title { set; get; } | |
/// <summary> | |
/// Specifies the json root title for any generic IEnumerable of the class decorated with this attribute. | |
/// </summary> | |
public string CollectionTitle { set; get; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment