PageRenderTime 50ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Atlassian.Jira/IssueFieldEditMetadata.cs

https://bitbucket.org/farmas/atlassian.net-sdk
C# | 85 lines | 38 code | 10 blank | 37 comment | 2 complexity | 8638d1ef828011be5729e66a609c8abf MD5 | raw file
Possible License(s): BSD-3-Clause
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Newtonsoft.Json.Linq;
  4. using Atlassian.Jira.Remote;
  5. namespace Atlassian.Jira
  6. {
  7. /// <summary>
  8. /// An issue field edit metadata as defined in JIRA.
  9. /// </summary>
  10. public class IssueFieldEditMetadata
  11. {
  12. /// <summary>
  13. /// Creates a new instance of IssueFieldEditMetadata based on a remote Entity
  14. /// </summary>
  15. /// <param name="remoteEntity">The remote field entity</param>
  16. public IssueFieldEditMetadata(RemoteIssueFieldMetadata remoteEntity)
  17. {
  18. IsRequired = remoteEntity.Required;
  19. Schema = remoteEntity.Schema == null ? null : new IssueFieldEditMetadataSchema(remoteEntity.Schema);
  20. Name = remoteEntity.name;
  21. AutoCompleteUrl = remoteEntity.AutoCompleteUrl;
  22. AllowedValues = remoteEntity.AllowedValues;
  23. HasDefaultValue = remoteEntity.HasDefaultValue;
  24. Operations = remoteEntity.Operations;
  25. }
  26. /// <summary>
  27. /// Whether this is a custom field.
  28. /// </summary>
  29. public bool IsCustom
  30. {
  31. get
  32. {
  33. return Schema.Custom != null;
  34. }
  35. }
  36. /// <summary>
  37. /// Whether the field is required.
  38. /// </summary>
  39. public bool IsRequired { get; private set; }
  40. /// <summary>
  41. /// Schema of this field.
  42. /// </summary>
  43. public IssueFieldEditMetadataSchema Schema { get; private set; }
  44. /// <summary>
  45. /// Name of this field.
  46. /// </summary>
  47. public string Name { get; private set; }
  48. /// <summary>
  49. /// The url to use in autocompletion.
  50. /// </summary>
  51. public string AutoCompleteUrl { get; private set; }
  52. /// <summary>
  53. /// Operations that can be done on this field.
  54. /// </summary>
  55. public IList<IssueFieldEditMetadataOperation> Operations { get; private set; }
  56. /// <summary>
  57. /// List of available allowed values that can be set. All objects in this array are of the same type.
  58. /// However there is multiple possible types it could be.
  59. /// You should decide what the type it is and convert to custom implemented type by yourself.
  60. /// </summary>
  61. public JArray AllowedValues { get; private set; }
  62. /// <summary>
  63. /// Whether the field has a default value.
  64. /// </summary>
  65. public bool HasDefaultValue { get; set; }
  66. /// <summary>
  67. /// List of field's available allowed values as object of class T which is ought to be implemented by user of this method.
  68. /// Conversion from serialized JObject to custom class T takes here place.
  69. /// </summary>
  70. public IEnumerable<T> AllowedValuesAs<T>()
  71. {
  72. return AllowedValues.Values<JObject>().Select(x => x.ToObject<T>());
  73. }
  74. }
  75. }