Ejemplo n.º 1
0
        internal override BrokeredMessage Execute(BrokeredMessage message, RuleExecutionContext context)
        {
            RuleAction ruleAction;

            this.Validate();
            foreach (PropertyReference initialize in this.Initializes)
            {
                if (initialize.PropertyName.Scope != PropertyScope.System)
                {
                    initialize.Value = message.Properties[initialize.PropertyName.Name];
                }
                else
                {
                    initialize.Value = message.GetSystemProperty(initialize.PropertyName.Name);
                }
            }
            Filter filter = this.FilterTemplate.Create();

            if (this.ActionTemplate != null)
            {
                ruleAction = this.ActionTemplate.Create();
            }
            else
            {
                ruleAction = null;
            }
            RuleAction      ruleAction1     = ruleAction;
            Guid            guid            = Guid.NewGuid();
            RuleDescription ruleDescription = new RuleDescription(guid.ToString(), filter)
            {
                Action = ruleAction1,
                Tag    = PropertyReference.GetValue <string>(this.Tag)
            };

            context.AddRule(ruleDescription);
            return(message);
        }
Ejemplo n.º 2
0
 public void AddRule(RuleDescription description)
 {
     this.ruleManager.AddRule(this.SubscriptionName, description);
 }
Ejemplo n.º 3
0
        internal override void UpdateForVersion(ApiVersion version, EntityDescription existingDescription = null)
        {
            RuleAction ruleAction;

            Microsoft.ServiceBus.Messaging.Filter filter;
            string          tag;
            DateTime?       internalCreatedAt;
            RuleAction      ruleAction1;
            string          str;
            RuleDescription ruleDescription = existingDescription as RuleDescription;

            base.UpdateForVersion(version, existingDescription);
            bool flag = false;

            if (version < ApiVersion.Two)
            {
                if (ruleDescription == null)
                {
                    tag = null;
                }
                else
                {
                    tag = ruleDescription.Tag;
                }
                this.Tag = tag;
                if (ruleDescription == null)
                {
                    internalCreatedAt = null;
                }
                else
                {
                    internalCreatedAt = ruleDescription.InternalCreatedAt;
                }
                this.InternalCreatedAt = internalCreatedAt;
                if (this.action is CompositeAction || this.action is RuleCreationAction)
                {
                    if (ruleDescription == null)
                    {
                        ruleAction1 = null;
                    }
                    else
                    {
                        ruleAction1 = ruleDescription.action;
                    }
                    this.action = ruleAction1;
                    flag        = true;
                }
                if (ruleDescription == null)
                {
                    str = null;
                }
                else
                {
                    str = ruleDescription.name;
                }
                this.name = str;
            }
            if (this.filter != null)
            {
                Microsoft.ServiceBus.Messaging.Filter filter1 = this.filter;
                ApiVersion apiVersion = version;
                if (ruleDescription == null)
                {
                    filter = null;
                }
                else
                {
                    filter = ruleDescription.filter;
                }
                filter1.UpdateForVersion(apiVersion, filter);
            }
            if (this.action != null && !flag)
            {
                RuleAction ruleAction2 = this.action;
                ApiVersion apiVersion1 = version;
                if (ruleDescription == null)
                {
                    ruleAction = null;
                }
                else
                {
                    ruleAction = ruleDescription.action;
                }
                ruleAction2.UpdateForVersion(apiVersion1, ruleAction);
            }
        }