static RuleAction ParseFromXElementSqlRuleAction(XElement xElement)
        {
            var expression = xElement.Element(XName.Get("SqlExpression", ManagementClientConstants.ServiceBusNamespace))?.Value;

            if (string.IsNullOrWhiteSpace(expression))
            {
                return(null);
            }

            var action = new SqlRuleAction(expression);

            var parameters = xElement.Element(XName.Get("Parameters", ManagementClientConstants.ServiceBusNamespace));

            if (parameters != null && parameters.HasElements)
            {
                foreach (var param in parameters.Elements(XName.Get("KeyValueOfstringanyType", ManagementClientConstants.ServiceBusNamespace)))
                {
                    var key   = param.Element(XName.Get("Key", ManagementClientConstants.ServiceBusNamespace))?.Value;
                    var value = XmlObjectConvertor.ParseValueObject(param.Element(XName.Get("Value", ManagementClientConstants.ServiceBusNamespace)));
                    action.Parameters.Add(key, value);
                }
            }

            return(action);
        }
Beispiel #2
0
        public static Filter ParseFromXElement(XElement xElement)
        {
            var expression = xElement.Element(XName.Get("SqlExpression", ManagementClientConstants.SbNs))?.Value;

            if (string.IsNullOrWhiteSpace(expression))
            {
                return(null);
            }

            var filter = new SqlFilter(expression);

            var parameters = xElement.Element(XName.Get("Parameters", ManagementClientConstants.SbNs));

            if (parameters != null && parameters.HasElements)
            {
                foreach (var param in parameters.Elements(XName.Get("KeyValueOfstringanyType", ManagementClientConstants.SbNs)))
                {
                    var key   = param.Element(XName.Get("Key", ManagementClientConstants.SbNs))?.Value;
                    var value = XmlObjectConvertor.ParseValueObject(param.Element(XName.Get("Value", ManagementClientConstants.SbNs)));
                    filter.Parameters.Add(key, value);
                }
            }

            return(filter);
        }
        public static Filter ParseFromXElement(XElement xElement)
        {
            var correlationFilter = new CorrelationFilter();

            foreach (var element in xElement.Elements())
            {
                switch (element.Name.LocalName)
                {
                case "CorrelationId":
                    correlationFilter.CorrelationId = element.Value;
                    break;

                case "MessageId":
                    correlationFilter.MessageId = element.Value;
                    break;

                case "To":
                    correlationFilter.To = element.Value;
                    break;

                case "ReplyTo":
                    correlationFilter.ReplyTo = element.Value;
                    break;

                case "Label":
                    correlationFilter.Label = element.Value;
                    break;

                case "SessionId":
                    correlationFilter.SessionId = element.Value;
                    break;

                case "ReplyToSessionId":
                    correlationFilter.ReplyToSessionId = element.Value;
                    break;

                case "ContentType":
                    correlationFilter.ContentType = element.Value;
                    break;

                case "Properties":
                    foreach (var prop in element.Elements(XName.Get("KeyValueOfstringanyType", ManagementClientConstants.ServiceBusNamespace)))
                    {
                        var key   = prop.Element(XName.Get("Key", ManagementClientConstants.ServiceBusNamespace))?.Value;
                        var value = XmlObjectConvertor.ParseValueObject(prop.Element(XName.Get("Value", ManagementClientConstants.ServiceBusNamespace)));
                        correlationFilter.Properties.Add(key, value);
                    }
                    break;

                default:
                    MessagingEventSource.Log.ManagementSerializationException(
                        $"{nameof(CorrelationFilterExtensions)}_{nameof(ParseFromXElement)}",
                        element.ToString());
                    break;
                }
            }

            return(correlationFilter);
        }