Extensions.cs 876 B

12345678910111213141516171819202122232425262728
  1. using Newtonsoft.Json.Linq;
  2. using System;
  3. namespace YJMPD_UWP.Helpers
  4. {
  5. public static class Extensions
  6. {
  7. public static bool NullOrEmpty(this JToken token)
  8. {
  9. return (token == null) ||
  10. (token.Type == JTokenType.Array && !token.HasValues) ||
  11. (token.Type == JTokenType.Object && !token.HasValues) ||
  12. (token.Type == JTokenType.String && token.ToString() == String.Empty) ||
  13. (token.Type == JTokenType.Null);
  14. }
  15. public static string UppercaseFirst(this string s)
  16. {
  17. // Check for empty string.
  18. if (string.IsNullOrEmpty(s))
  19. {
  20. return string.Empty;
  21. }
  22. // Return char and concat substring.
  23. return char.ToUpper(s[0]) + s.Substring(1).ToLower();
  24. }
  25. }
  26. }