Exemplo n.º 1
0
        private static bool Before(Command command, Object obj)
        {
            if (obj != null)
            {
                Func <bool> before = obj.Before(command.Verb.GetType());
                if (before != null)
                {
                    return(before());
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        private bool Before(Command command, Object obj)
        {
            if (obj != null)
            {
                objectInPlay = obj;
                var before = obj.Before(command.Verb.GetType());
                if (before != null)
                {
                    return(before());
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        private bool HandleObjects(CommandContext context, ICommandState commandState)
        {
            bool failed = false;

            foreach (var obj in objects)
            {
                context.Noun = obj;

                bool handled = false;

                var before = obj.Before(verbType);

                if (before != null)
                {
                    commandState.State = CommandState.Before;
                    handled            = before();
                }

                if (indirectObject != null)
                {
                    before = indirectObject.Before(verbType);

                    if (before != null)
                    {
                        commandState.State = CommandState.Before;
                        handled            = before();
                    }
                }

                if (!handled)
                {
                    commandState.State = CommandState.During;
                    bool success = Expects(verb, obj, commandState);

                    if (success)
                    {
                        var after = obj.After(verbType);

                        if (after != null)
                        {
                            commandState.State = CommandState.After;
                            after();
                        }

                        if (indirectObject != null)
                        {
                            after = indirectObject.After(verbType);

                            if (after != null)
                            {
                                commandState.State = CommandState.After;
                                after();
                            }
                        }
                    }
                    else
                    {
                        failed = true;
                        break;
                    }
                }
            }

            return(failed);
        }