Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CustomContractResolver : DefaultContractResolver
- {
- protected override JsonContract CreateContract(Type objectType)
- {
- var contract = base.CreateContract(objectType);
- if (objectType == typeof(decimal))
- {
- //Not sure this will actually give you the attribute, haven't tested it
- var custom = objectType.GetCustomAttributes(true).OfType<AvroFieldAttribute>().SingleOrDefault();
- if (custom != null)
- {
- contract.Converter = new AvroDecimalJsonConverter(custom.Precision, custom.Scale);
- }
- }
- return contract;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement