コード例 #1
0
        /// <summary>
        /// Executes the transition action.
        /// </summary>
        /// <param name="argument">The state machine event argument.</param>
        public void Execute(object argument)
        {
            if (argument != null && !(argument is T))
            {
                throw new ArgumentException(ActionHoldersExceptionMessages.CannotCastArgumentToActionArgument(argument, this.Describe()));
            }

            this.action((T)argument);
        }
コード例 #2
0
        public void Execute(object argument)
        {
            T castArgument = default(T);

            if (argument != Missing.Value && argument != null && !(argument is T))
            {
                throw new ArgumentException(ActionHoldersExceptionMessages.CannotCastArgumentToActionArgument(argument, this.Describe()));
            }

            if (argument != Missing.Value)
            {
                castArgument = (T)argument;
            }

            this.action(castArgument);
        }
コード例 #3
0
        protected override Action GetActionCall(object argument, CancellationToken cancellation)
        {
            T castArgument = default(T);

            if (argument != Missing.Value && !(argument is T))
            {
                throw new ArgumentException(ActionHoldersExceptionMessages.CannotCastArgumentToActionArgument(argument, this.Describe()));
            }

            if (argument != Missing.Value)
            {
                castArgument = (T)argument;
            }

            return(() => this.action(castArgument, cancellation));
        }