Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Dictionary<string, Type> GetTypeJsonPropertyNamesAndTypes<T>()
- {
- var pairs = typeof(T)
- .GetProperties()
- .Select(p => new {
- Property = p,
- Attribute = p
- .GetCustomAttributes(
- typeof(JsonPropertyAttribute), true)
- .Cast<JsonPropertyAttribute>()
- .FirstOrDefault()
- });
- return pairs
- .Where(p => p.Attribute != null)
- .ToDictionary(
- p => p.Attribute.PropertyName,
- p => p.Property.PropertyType);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement