示例#1
0
    /// <summary>
    /// Retrieve a custom field from an agile issue
    /// </summary>
    /// <param name="issue">AgileIssue to retrieve custom field value from</param>
    /// <param name="customFieldName">string with the name of the custom field</param>
    /// <param name="value">string</param>
    /// <returns>bool</returns>
    public static bool TryGetCustomField(this AgileIssue issue, string customFieldName, out string value)
    {
        var customFields = issue.Fields.CustomFields;

        if (customFields == null || !customFields.ContainsKey(customFieldName))
        {
            value = null;
            return(false);
        }
        value = issue.Fields.CustomFields[customFieldName]?.ToString();
        return(true);
    }
示例#2
0
    /// <summary>
    /// Try to retrieve a custom field from an agile issue
    /// </summary>
    /// <typeparam name="TCustomField">type for the custom field</typeparam>
    /// <param name="issue">AgileIssue to retrieve custom field value from</param>
    /// <param name="customFieldName">string with the name of the custom field</param>
    /// <param name="value">TCustomField</param>
    /// <returns>bool</returns>
    public static bool TryGetCustomField <TCustomField>(this AgileIssue issue, string customFieldName, out TCustomField value)
    {
        var customFields = issue.Fields.CustomFields;

        if (customFields == null || !customFields.ContainsKey(customFieldName))
        {
            value = default;
            return(false);
        }
        var stringValue = issue.Fields.CustomFields[customFieldName]?.ToString();

        if (stringValue is null)
        {
            value = default;
        }
        else
        {
            value = JsonConvert.DeserializeObject <TCustomField>(stringValue);
        }
        return(true);
    }
示例#3
0
 /// <summary>
 /// Retrieve a custom field from an agile issue
 /// </summary>
 /// <param name="issue">AgileIssue to retrieve custom field value from</param>
 /// <param name="customFieldName">string with the name of the custom field</param>
 /// <returns>string</returns>
 public static string GetCustomField(this AgileIssue issue, string customFieldName)
 {
     issue.TryGetCustomField(customFieldName, out var returnValue);
     return(returnValue);
 }