Last active
January 17, 2017 20:08
-
-
Save hmdhk/581f7281e90179c1aa38 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
using System; | |
using System.Reflection; | |
using Microsoft.AspNet.SignalR.Infrastructure; | |
using Newtonsoft.Json.Serialization; | |
namespace SignalR | |
{ | |
public class SignalRContractResolver : DefaultContractResolver | |
{ | |
private readonly Assembly _assembly; | |
private readonly IContractResolver _camelCaseContractResolver; | |
private readonly IContractResolver _defaultContractSerializer; | |
public SignalRContractResolver() | |
{ | |
_defaultContractSerializer = new DefaultContractResolver(); | |
_camelCaseContractResolver = new CamelCasePropertyNamesContractResolver(); | |
_assembly = typeof(Connection).Assembly; | |
} | |
public override JsonContract ResolveContract(Type type) | |
{ | |
if (type.Assembly.Equals(_assembly)) | |
{ | |
return _defaultContractSerializer.ResolveContract(type); | |
} | |
return _camelCaseContractResolver.ResolveContract(type); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment