PageRenderTime 46ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Atlassian.Jira/IssueStatus.cs

https://bitbucket.org/yyo/atlassian.net-sdk-v2.0
C# | 101 lines | 76 code | 7 blank | 18 comment | 17 complexity | 4564d315b4a268f77510d909fa34c750 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Atlassian.Jira.Remote;
  6. namespace Atlassian.Jira
  7. {
  8. /// <summary>
  9. /// The status of the issue as defined in JIRA
  10. /// </summary>
  11. public class IssueStatus : JiraNamedEntity
  12. {
  13. internal IssueStatus(AbstractNamedRemoteEntity remoteEntity)
  14. : base(remoteEntity)
  15. {
  16. }
  17. internal IssueStatus(Jira jira, string id)
  18. : base(jira, id)
  19. {
  20. }
  21. internal IssueStatus(string name)
  22. : base(name)
  23. {
  24. }
  25. protected override IEnumerable<JiraNamedEntity> GetEntities(Jira jira, string projectKey = null)
  26. {
  27. return jira.GetIssueStatuses();
  28. }
  29. /// <summary>
  30. /// Allows assignation by name
  31. /// </summary>
  32. public static implicit operator IssueStatus(string name)
  33. {
  34. if (name != null)
  35. {
  36. int id;
  37. if (int.TryParse(name, out id))
  38. {
  39. return new IssueStatus(null, name /*as id*/);
  40. }
  41. else
  42. {
  43. return new IssueStatus(name);
  44. }
  45. }
  46. else
  47. {
  48. return null;
  49. }
  50. }
  51. /// <summary>
  52. /// Operator overload to simplify LINQ queries
  53. /// </summary>
  54. /// <remarks>
  55. /// Allows calls in the form of issue.Priority == "High"
  56. /// </remarks>
  57. public static bool operator ==(IssueStatus entity, string name)
  58. {
  59. if ((object)entity == null)
  60. {
  61. return name == null;
  62. }
  63. else if (name == null)
  64. {
  65. return false;
  66. }
  67. else
  68. {
  69. return entity._name == name;
  70. }
  71. }
  72. /// <summary>
  73. /// Operator overload to simplify LINQ queries
  74. /// </summary>
  75. /// <remarks>
  76. /// Allows calls in the form of issue.Priority != "High"
  77. /// </remarks>
  78. public static bool operator !=(IssueStatus entity, string name)
  79. {
  80. if ((object)entity == null)
  81. {
  82. return name != null;
  83. }
  84. else if (name == null)
  85. {
  86. return true;
  87. }
  88. else
  89. {
  90. return entity._name != name;
  91. }
  92. }
  93. }
  94. }