コード例 #1
0
        /// <inheritdoc/>
        public override bool Equals(RuleFilter other)
        {
            if (other is CorrelationRuleFilter correlationRuleFilter)
            {
                if (string.Equals(CorrelationId, correlationRuleFilter.CorrelationId, StringComparison.OrdinalIgnoreCase) &&
                    string.Equals(MessageId, correlationRuleFilter.MessageId, StringComparison.OrdinalIgnoreCase) &&
                    string.Equals(To, correlationRuleFilter.To, StringComparison.OrdinalIgnoreCase) &&
                    string.Equals(ReplyTo, correlationRuleFilter.ReplyTo, StringComparison.OrdinalIgnoreCase) &&
                    string.Equals(Label, correlationRuleFilter.Label, StringComparison.OrdinalIgnoreCase) &&
                    string.Equals(SessionId, correlationRuleFilter.SessionId, StringComparison.OrdinalIgnoreCase) &&
                    string.Equals(ReplyToSessionId, correlationRuleFilter.ReplyToSessionId, StringComparison.OrdinalIgnoreCase) &&
                    string.Equals(ContentType, correlationRuleFilter.ContentType, StringComparison.OrdinalIgnoreCase))
                {
                    if (Properties.Count != correlationRuleFilter.Properties.Count)
                    {
                        return(false);
                    }

                    foreach (var param in Properties)
                    {
                        if (!correlationRuleFilter.Properties.TryGetValue(param.Key, out var otherParamValue) ||
                            (param.Value == null ^ otherParamValue == null) ||
                            (param.Value != null && !param.Value.Equals(otherParamValue)))
                        {
                            return(false);
                        }
                    }

                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        /// <inheritdoc/>
        public override bool Equals(RuleFilter other)
        {
            if (other is SqlRuleFilter sqlRuleFilter)
            {
                if (string.Equals(SqlExpression, sqlRuleFilter.SqlExpression, StringComparison.OrdinalIgnoreCase) &&
                    (parameters != null && sqlRuleFilter.parameters != null ||
                     parameters == null && sqlRuleFilter.parameters == null))
                {
                    if (parameters != null)
                    {
                        if (parameters.Count != sqlRuleFilter.parameters.Count)
                        {
                            return(false);
                        }

                        foreach (var param in parameters)
                        {
                            if (!sqlRuleFilter.parameters.TryGetValue(param.Key, out var otherParamValue) ||
                                (param.Value == null ^ otherParamValue == null) ||
                                (param.Value != null && !param.Value.Equals(otherParamValue)))
                            {
                                return(false);
                            }
                        }
                    }

                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        public static XElement Serialize(this RuleFilter filter)
        {
            switch (filter)
            {
            case SqlRuleFilter sqlRuleFilter:
                switch (sqlRuleFilter)
                {
                case TrueRuleFilter _:
                    return(sqlRuleFilter.Serialize("TrueFilter"));

                case FalseRuleFilter _:
                    return(sqlRuleFilter.Serialize("FalseFilter"));

                default:
                    return(sqlRuleFilter.Serialize("SqlFilter"));
                }

            case CorrelationRuleFilter correlationRuleFilter:
                return(correlationRuleFilter.Serialize("CorrelationFilter"));

            default:
                throw new NotImplementedException($"filter type {filter.GetType().Name} is not supported.");
            }
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RuleProperties" /> class with the specified name and filter expression.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="filter">The filter expression used to match messages.</param>
 public RuleProperties(string name, RuleFilter filter)
 {
     Argument.AssertNotNull(filter, nameof(filter));
     Filter = filter;
     Name   = name;
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RuleDescription" /> class with the specified name and filter expression.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="filter">The filter expression used to match messages.</param>
 public RuleDescription(string name, RuleFilter filter)
 {
     Argument.AssertNotNull(filter, nameof(filter));
     Filter = filter;
     Name   = name;
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateRuleOptions" /> class with the specified name and filter expression.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="filter">The filter expression used to match messages.</param>
 public CreateRuleOptions(string name, RuleFilter filter)
 {
     Argument.AssertNotNull(filter, nameof(filter));
     Filter = filter;
     Name   = name;
 }