public override void Execute(WxeContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);

            if (_wxeHandler != null)
            {
                context.HttpContext.Handler = _wxeHandler;
                _wxeHandler = null;
            }

            if (!_isExecutionStarted)
            {
                _isExecutionStarted = true;
                _isPostBack         = false;
            }
            else
            {
                _isPostBack = true;
            }

            _userControlExecutor.Execute(context);

            try
            {
                PageStep.PageExecutor.ExecutePage(context, PageStep.Page, PageStep.IsPostBack);
            }
            finally
            {
                if (_userControlExecutor.IsReturningPostBack)
                {
                    _userControlExecutor = NullUserControlExecutor.Null;
                }
            }
        }
        protected override sealed void OnInit(EventArgs e)
#pragma warning restore 0809
        {
            if (!_isWxeInfoInitialized)
            {
                _wxeInfo.Initialize(Context);
                _isWxeInfoInitialized = true;
            }

            if (_replacer == null)
            {
                var replacer = new ControlReplacer(new InternalControlMemberCaller());
                replacer.ID = ID + "_Parent";

                _permanentUniqueID = UniqueID.Insert(UniqueID.Length - ID.Length, replacer.ID + IdSeparator);

                IUserControlExecutor userControlExecutor = GetUserControlExecutor();

                WxeUserControl             control;
                IStateModificationStrategy stateModificationStrategy;
                if (!userControlExecutor.IsNull && !userControlExecutor.IsReturningPostBack)
                {
                    Assertion.IsTrue(userControlExecutor.UserControlID == _permanentUniqueID);
                    var currentUserControlStep = (WxeUserControlStep)userControlExecutor.Function.ExecutingStep;
                    control = (WxeUserControl)Page.LoadControl(currentUserControlStep.UserControl);

                    if (!currentUserControlStep.IsPostBack)
                    {
                        stateModificationStrategy = new StateClearingStrategy();
                    }
                    else
                    {
                        stateModificationStrategy = new StateLoadingStrategy();
                    }
                }
                else
                {
                    if (userControlExecutor.IsReturningPostBack)
                    {
                        control = (WxeUserControl)Page.LoadControl(userControlExecutor.BackedUpUserControl);
                        stateModificationStrategy = new StateReplacingStrategy(userControlExecutor.BackedUpUserControlState);
                    }
                    else
                    {
                        control = this;
                        stateModificationStrategy = new StateLoadingStrategy();
                    }
                }

                control.ID = ID;
                control._permanentUniqueID = _permanentUniqueID;
                replacer.ReplaceAndWrap(this, control, stateModificationStrategy);
            }
            else
            {
                CompleteInitialization();
            }
        }
        private IUserControlExecutor GetUserControlExecutor()
        {
            IUserControlExecutor userControlExecutor = CurrentPageStep.UserControlExecutor;

            if (!userControlExecutor.IsNull && !userControlExecutor.IsReturningPostBack && !CurrentUserControlStep.UserControlExecutor.IsNull)
            {
                userControlExecutor = CurrentUserControlStep.UserControlExecutor;
            }
            return(userControlExecutor);
        }
        /// <summary>
        ///   Displays the <see cref="WxePageStep"/>'s page or the sub-function that has been invoked by the
        ///   <see cref="ExecuteFunction(Infrastructure.WxePageStepExecutionStates.PreProcessingSubFunctionStateParameters,Infrastructure.WxeRepostOptions)"/> method.
        /// </summary>
        /// <include file='..\doc\include\ExecutionEngine\WxePageStep.xml' path='WxePageStep/Execute/*' />
        public override void Execute(WxeContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);

            if (_wxeHandler != null)
            {
                context.HttpContext.Handler = _wxeHandler;
                _wxeHandler = null;
            }

            if (!_isExecutionStarted)
            {
                _isExecutionStarted = true;
                _isPostBack         = false;
            }
            else
            {
                _isPostBack = true;
            }

            ClearIsOutOfSequencePostBack();
            ClearReturnState();

            while (_executionState.IsExecuting)
            {
                _executionState.ExecuteSubFunction(context);
            }

            _userControlExecutor.Execute(context);

            try
            {
                _pageExecutor.ExecutePage(context, Page, _isPostBack);
            }
            finally
            {
                if (_userControlExecutor.IsReturningPostBack)
                {
                    _userControlExecutor = NullUserControlExecutor.Null;
                }

                ClearIsOutOfSequencePostBack();
                ClearReturnState();
            }
        }
        public void ExecuteFunction(WxeUserControl userControl, WxeFunction subFunction, Control sender, bool usesEventTarget)
        {
            ArgumentUtility.CheckNotNull("userControl", userControl);
            ArgumentUtility.CheckNotNull("subFunction", subFunction);
            ArgumentUtility.CheckNotNull("sender", sender);

            IWxePage wxePage = userControl.WxePage;

            _wxeHandler = wxePage.WxeHandler;

            _userControlExecutor = new UserControlExecutor(this, userControl, subFunction, sender, usesEventTarget);

            IReplaceableControl replaceableControl = userControl;

            replaceableControl.Replacer.Controls.Clear();
            wxePage.SaveAllState();

            Execute();
        }
 public void SetUserControlExecutor(IUserControlExecutor userControlExecutor)
 {
     ArgumentUtility.CheckNotNull("userControlExecutor", userControlExecutor);
     _userControlExecutor = userControlExecutor;
 }