Beispiel #1
0
        public void AddExpression(ConditionalExpression expression)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("Expression was null.");
            }
            var resolvedExpr = ResolvedConditionalExpression.CreateFromUnresolved(expression);

            if (!resolvedExpr.IsValid())
            {
                throw new Exception("Expression was not valid.");
            }

            // Remove all expressions that have the same conditional resource target as the newest one
            // We will replace those with what the new rule.
            int removed = m_pendingExpressions.RemoveAll(x => x.ConditionalResource.Id == resolvedExpr.ConditionalResource.Id);

            for (int i = 0; i < removed; i++)
            {
                GatewayResourceProxy.Instance.UnregisterOnMessageEvent(resolvedExpr.ConditionalResource.Id, OnMessage);
            }

            m_pendingExpressions.Add(resolvedExpr);
            this.PrepareConditionalObject(resolvedExpr);
        }
Beispiel #2
0
 private void PrepareConditionalObject(ResolvedConditionalExpression expr)
 {
     // We will be watching changes of this resources' value, so set its mode to push
     GatewayResourceProxy.Instance.RegisterOnMessageEvent(expr.ConditionalResource.Id, OnMessage);
     GatewayResourceProxy.Instance.SendSetCommunicationModeRequest(expr.ConditionalResource.Id,
                                                                   CommunicationMode.Push);
 }
Beispiel #3
0
        public static ResolvedConditionalExpression CreateFromUnresolved(ConditionalExpression unresolvedExpr)
        {
            var resolved = new ResolvedConditionalExpression(unresolvedExpr);

            resolved.Resolve();
            return(resolved);
        }
Beispiel #4
0
 private void ExecuteExpression(ResolvedConditionalExpression expr, MessageReceivedEventArgs e)
 {
     expr.Execute(e.Data);
 }