Beispiel #1
0
        /// <summary>
        ///     Adds the in queue.
        /// </summary>
        /// <param name="balancedDraw">The balanced draw.</param>
        /// <param name="action">The action.</param>
        /// <param name="isEditor">if set to <c>true</c> [is editor].</param>
        /// <param name="extender">The extender.</param>
        /// <param name="storedPredicate">The stored predicate.</param>
        /// <exception cref="ArgumentNullException">action</exception>
        public static void AddInQueue(UIBalancedDraw balancedDraw, Expression <Action <object[]> > action, bool isEditor,
                                      ExpressionExtender extender = null, Func <bool> storedPredicate = null)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            // If Editor, add once the actions to list
            // Else, call them (draw it)

            if (storedPredicate != null)
            {
                AddStoredPredicate(balancedDraw, action, extender, storedPredicate);
            }

            if (isEditor)
            {
                Add(balancedDraw, action, extender);
            }
            else
            {
                ExecuteCompiledAction(action, extender);
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Adds the stored predicate.
        /// </summary>
        /// <param name="balancedDraw">The balanced draw.</param>
        /// <param name="action">The action.</param>
        /// <param name="extender">The extender.</param>
        /// <param name="storedPredicate">The stored predicate.</param>
        /// <returns></returns>
        private static bool AddStoredPredicate(UIBalancedDraw balancedDraw, Expression <Action <object[]> > action,
                                               ExpressionExtender extender, Func <bool> storedPredicate)
        {
            var key = GetKey(action, extender);

            if (balancedDraw.m_predicates.ContainsKey(key))
            {
                return(false);
            }

            balancedDraw.m_predicates.Add(key, storedPredicate);

            return(true);
        }
Beispiel #3
0
        /// <summary>
        ///     Adds the in queue.
        /// </summary>
        /// <param name="balancedDraw">The balanced draw.</param>
        /// <param name="action">The action.</param>
        /// <param name="isEditor">if set to <c>true</c> [is editor].</param>
        /// <param name="predicate">The predicate.</param>
        /// <param name="extender">The extender.</param>
        /// <param name="storedPredicate">The stored predicate.</param>
        /// <exception cref="ArgumentNullException">predicate</exception>
        public static void AddInQueue(UIBalancedDraw balancedDraw, Expression <Action <object[]> > action, bool isEditor,
                                      Func <bool> predicate, ExpressionExtender extender = null, Func <bool> storedPredicate = null)
        {
            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }

            if (predicate())
            {
                AddInQueue(balancedDraw, action, isEditor, extender, storedPredicate);
            }
            else
            {
                ExecuteCompiledAction(action, extender);
            }
        }
Beispiel #4
0
        /// <summary>
        ///     Adds the specified balanced draw.
        /// </summary>
        /// <param name="balancedDraw">The balanced draw.</param>
        /// <param name="action">The action.</param>
        /// <param name="extender">The extender.</param>
        /// <returns></returns>
        /// <exception cref="NullReferenceException"></exception>
        private static bool Add(UIBalancedDraw balancedDraw, Expression <Action <object[]> > action,
                                ExpressionExtender extender)
        {
            var key = GetKey(action, extender);

            if (balancedDraw.m_actions.ContainsKey(key))
            {
                return(false);
            }

            var compiledAction = action.Compile();

            if (compiledAction == null)
            {
                throw new NullReferenceException(NullCompiledActionMessage);
            }

            balancedDraw.m_actions.Add(key, compiledAction);
            balancedDraw.m_extenders.Add(key, extender);

            return(true);
        }