32 lines
1.3 KiB
C#
32 lines
1.3 KiB
C#
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Serialization;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Knoks.Api.Entities
|
|
{
|
|
[JsonDictionary(
|
|
NamingStrategyType = typeof(DictionaryCamelCaseNamingStrategy),
|
|
NamingStrategyParameters = new object[] { true, false })]
|
|
///Solves camel case issues with validation property names
|
|
internal class PropertyDictionary<T> : Dictionary<string, T>
|
|
{
|
|
public PropertyDictionary() { }
|
|
public PropertyDictionary(IDictionary<string, T> dictionary) : base(dictionary) { }
|
|
}
|
|
|
|
internal class DictionaryCamelCaseNamingStrategy : CamelCaseNamingStrategy
|
|
{
|
|
public DictionaryCamelCaseNamingStrategy() { }
|
|
public DictionaryCamelCaseNamingStrategy(bool processDictionaryKeys, bool overrideSpecifiedNames) : base(processDictionaryKeys, overrideSpecifiedNames) { }
|
|
public DictionaryCamelCaseNamingStrategy(bool processDictionaryKeys, bool overrideSpecifiedNames, bool processExtensionDataNames): base(processDictionaryKeys, overrideSpecifiedNames, processExtensionDataNames) { }
|
|
|
|
public override string GetDictionaryKey(string key)
|
|
{
|
|
return string.Join(".", key.Split(".").Select(it => base.GetDictionaryKey(it)));
|
|
}
|
|
}
|
|
}
|