SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public Dictionary<string, object> ToDictionary()
  2. {
  3.   return this.GetType()
  4.     .GetProperties(BindingFlags.Instance | BindingFlags.Public)
  5.     .Where(prop => prop.GetCustomAttribute<JsonPropertyAttribute>() != null && prop.GetValue(this, null) != null && !string.IsNullOrEmpty(prop.GetValue(this, null).ToString()))
  6.     .ToDictionary(prop => prop.GetCustomAttribute<JsonPropertyAttribute>().PropertyName, prop => prop.GetValue(this, null));
  7. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top