示例#1
0
        public static Func <JiraIssueDto[], JiraIssueDto, bool> Contains(string propertyName, Type propertyType,
                                                                         string value)
        {
            var directly = false;

            if (string.IsNullOrEmpty(value))
            {
                throw new JqlCompilationException($"value of the field [{propertyName}] can not be null or empty");
            }
            if (propertyType != typeof(string))
            {
                throw new JqlCompilationException(
                          $"can not use ~ operator for field [{propertyName}] because field type is not [String]");
            }
            if (value[0] == '\'')
            {
                value = value.Trim('\'').Replace("\'\'", "'");
            }
            else if (value[0] == '\"' || value[value.Length - 1] == '\"')
            {
                try
                {
                    value    = StringHelpers.Unescape(value);
                    directly = true;
                }
                catch (Exception)
                {
                    throw new JqlCompilationException(
                              $"value [{value}] has incorrect format, field [{propertyName}]");
                }
            }

            return((issues, issue) =>
            {
                var actualValue = issue.IssueFields.GetProperty <string>(propertyName);
                if (actualValue == null)
                {
                    return false;
                }
                return directly
                    ? FilterFunctions.SearchDirectly(actualValue, value)
                    : FilterFunctions.Search(actualValue, value);
            });
        }
示例#2
0
        private static bool Equals(JiraIssueDto issue, string propertyName, Type propertyType, string value)
        {
            if (Equals(propertyName, "key"))
            {
                return(Equals(issue.Key, value));
            }
            if (Equals(propertyName, "id"))
            {
                return(Equals(issue.Id, value));
            }
            if (Equals(propertyName, "self"))
            {
                return(Equals(issue.Self, value));
            }
            if (Equals(propertyName, "statuscategory"))
            {
                var actualStatus = issue.IssueFields.GetProperty <JiraStatus>("status");
                return(actualStatus != (JiraStatus)null && actualStatus.StatusCategory == value);
            }
            var actualValue = issue.IssueFields.GetProperty(propertyName, propertyType);

            return(FilterFunctions.Equals(actualValue, value));
        }