Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Dictionary<string, object> ToDictionary()
- {
- return this.GetType()
- .GetProperties(BindingFlags.Instance | BindingFlags.Public)
- .Where(prop => prop.GetCustomAttribute<JsonPropertyAttribute>() != null && prop.GetValue(this, null) != null && !string.IsNullOrEmpty(prop.GetValue(this, null).ToString()))
- .ToDictionary(prop => prop.GetCustomAttribute<JsonPropertyAttribute>().PropertyName, prop => prop.GetValue(this, null));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement