/// <summary>
        /// Defines the method to be called when the command is invoked.
        /// </summary>
        /// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to null.</param>
        public void Execute(object parameter)
        {
            var method      = DynamicDelegate.From(context.Method);
            var returnValue = method(context.Target, new object[0]);

            var task = returnValue as System.Threading.Tasks.Task;

            if (task != null)
            {
                returnValue = task.AsResult();
            }

            var result = returnValue as IResult;

            if (result != null)
            {
                returnValue = new[] { result };
            }

            var enumerable = returnValue as IEnumerable <IResult>;

            if (enumerable != null)
            {
                returnValue = enumerable.GetEnumerator();
            }

            var enumerator = returnValue as IEnumerator <IResult>;

            if (enumerator != null)
            {
                Coroutine.BeginExecute(enumerator, context);
            }
        }
        /// <summary>
        /// Defines the method to be called when the command is invoked.
        /// </summary>
        /// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to null.</param>
        public void Execute(object parameter)
        {
            var target = targetReference.Target;

            if (target == null)
            {
                return;
            }

            var execute     = DynamicDelegate.From(method);
            var returnValue = execute(target, new object[0]);

            var task = returnValue as System.Threading.Tasks.Task;

            if (task != null)
            {
                returnValue = task.AsResult();
            }

            var result = returnValue as IResult;

            if (result != null)
            {
                returnValue = new[] { result };
            }

            var enumerable = returnValue as IEnumerable <IResult>;

            if (enumerable != null)
            {
                returnValue = enumerable.GetEnumerator();
            }

            var enumerator = returnValue as IEnumerator <IResult>;

            if (enumerator != null)
            {
                var context = new CoroutineExecutionContext
                {
                    Target = target,
                };

                Coroutine.BeginExecute(enumerator, context);
            }
        }