ApiList.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Newtonsoft.Json;
  8. using Newtonsoft.Json.Linq;
  9. namespace cuidian.OpenApi.Utils
  10. {
  11. public class ApiList
  12. {
  13. private JArray array;
  14. public ApiList(JArray array)
  15. {
  16. this.array = array;
  17. }
  18. public JArray GetJArray()
  19. {
  20. return array;
  21. }
  22. public IList GetArray()
  23. {
  24. return array;
  25. }
  26. public int Count
  27. {
  28. get { return array.Count; }
  29. }
  30. public ApiDictionary this[int index]
  31. {
  32. get { return this.GetObject(index); }
  33. }
  34. public ApiDictionary GetObject(int index)
  35. {
  36. Type t = array[index].GetType();
  37. if (t.FullName.Equals("Newtonsoft.Json.Linq.JObject", StringComparison.CurrentCultureIgnoreCase))
  38. {
  39. return JsonConvert.DeserializeObject<ApiDictionary>(array[index].ToString());
  40. }
  41. return null;
  42. }
  43. public override string ToString()
  44. {
  45. return JsonConvert.SerializeObject(array);
  46. }
  47. }
  48. }