public static AmqpRuleDescription GetRuleDescription(RuleDescription description) { AmqpFilter filter = MessageConverter.GetFilter(description.Filter); AmqpRuleAction ruleAction = MessageConverter.GetRuleAction(description.Action); return(new AmqpRuleDescription() { Filter = filter, Action = ruleAction }); }
private static RuleAction GetRuleAction(AmqpRuleAction amqpAction) { RuleAction @default; if (amqpAction.DescriptorCode != AmqpEmptyRuleAction.Code) { if (amqpAction.DescriptorCode != AmqpSqlRuleAction.Code) { throw new NotSupportedException(); } AmqpSqlRuleAction amqpSqlRuleAction = (AmqpSqlRuleAction)amqpAction; @default = (!amqpSqlRuleAction.CompatibilityLevel.HasValue ? new SqlRuleAction(amqpSqlRuleAction.SqlExpression) : new SqlRuleAction(amqpSqlRuleAction.SqlExpression, amqpSqlRuleAction.CompatibilityLevel.Value)); } else { @default = EmptyRuleAction.Default; } return(@default); }
private static AmqpRuleAction GetRuleAction(RuleAction ruleAction) { AmqpRuleAction amqpEmptyRuleAction = null; if (ruleAction == null || ruleAction is EmptyRuleAction) { amqpEmptyRuleAction = new AmqpEmptyRuleAction(); } else { if (!(ruleAction is SqlRuleAction)) { throw new NotSupportedException(); } AmqpSqlRuleAction amqpSqlRuleAction = new AmqpSqlRuleAction(); SqlRuleAction sqlRuleAction = (SqlRuleAction)ruleAction; amqpSqlRuleAction.SqlExpression = sqlRuleAction.SqlExpression; amqpSqlRuleAction.CompatibilityLevel = new int?(sqlRuleAction.CompatibilityLevel); amqpEmptyRuleAction = amqpSqlRuleAction; } return(amqpEmptyRuleAction); }