public static ClassWithAllDataTypes Call(IWxePage page, WxeUserControl userControl, Control sender, ITransactionMode transactionMode, ClassWithAllDataTypes inParameter) { ArgumentUtility.CheckNotNull("page", page); ArgumentUtility.CheckNotNull("userControl", userControl); ArgumentUtility.CheckNotNull("sender", sender); if (page.IsReturningPostBack == false) { var function = new ShowSecondUserControlFunction(transactionMode, inParameter); function.ExceptionHandler.SetCatchExceptionTypes(typeof(System.Exception)); var actualUserControl = (WxeUserControl)page.FindControl(userControl.PermanentUniqueID); Assertion.IsNotNull(actualUserControl); actualUserControl.ExecuteFunction(function, sender, null); throw new Exception("(Unreachable code)"); } else { var function = (ShowSecondUserControlFunction)page.ReturningFunction; if (function.ExceptionHandler.Exception != null) { throw function.ExceptionHandler.Exception; } return(function.ReturnedObjectWithAllDataTypes); } }
protected UserControlExecutor(WxeStep parentStep, WxeUserControl userControl, WxeFunction subFunction, Control sender, bool usesEventTarget) { ArgumentUtility.CheckNotNull("parentStep", parentStep); ArgumentUtility.CheckNotNull("userControl", userControl); ArgumentUtility.CheckNotNull("subFunction", subFunction); ArgumentUtility.CheckNotNull("sender", sender); if (userControl.WxePage == null) { throw new ArgumentException("Execution of user controls that are no longer part of the control hierarchy is not supported.", "userControl"); } _backedUpUserControlState = userControl.SaveAllState(); _backedUpUserControl = userControl.AppRelativeVirtualPath; _userControlID = userControl.UniqueID; _function = subFunction; _function.SetParentStep(parentStep); if (parentStep is WxeUserControlStep) { _pageStep = ((WxeUserControlStep)parentStep).PageStep; } else { _pageStep = ((WxePageStep)parentStep); } if (userControl.WxePage.IsPostBack) { _postBackCollection = userControl.WxePage.GetPostBackCollection().Clone(); _backedUpPostBackData = new NameValueCollection(); if (usesEventTarget) { //TODO: Update PreProcessingSubFunctionState with this check as well. if (sender.UniqueID.Contains(":")) { throw new InvalidOperationException("Executing WxeUserControls are only supported on pages not rendered in XhtmlConformanceMode.Legacy."); } //TODO: Is this check really necessary? if (_postBackCollection[ControlHelper.PostEventSourceID] != sender.UniqueID) { throw new ArgumentException( string.Format( "The 'sender' does not match the value in {0}. Please pass the control that orignated the postback.", ControlHelper.PostEventSourceID), "sender"); } _backedUpPostBackData.Add(ControlHelper.PostEventSourceID, _postBackCollection[ControlHelper.PostEventSourceID]); _backedUpPostBackData.Add(ControlHelper.PostEventArgumentID, _postBackCollection[ControlHelper.PostEventArgumentID]); _postBackCollection.Remove(ControlHelper.PostEventSourceID); _postBackCollection.Remove(ControlHelper.PostEventArgumentID); } else { throw new InvalidOperationException( "The WxeUserControl does not support controls that do not use __EventTarget for signaling a postback event."); //TODO: Check if controls that do not use __EventTarget can be supported // _backedUpPostBackData.Add (sender.UniqueID, _postBackCollection[sender.UniqueID]); // _postBackCollection.Remove (sender.UniqueID); } string uniqueIDPrefix = _userControlID + userControl.Page.IdSeparator; foreach (var key in _postBackCollection.AllKeys.Where(s => s.StartsWith(uniqueIDPrefix))) { _backedUpPostBackData.Add(key, _postBackCollection[key]); _postBackCollection.Remove(key); } } }
public UserControlExecutor(WxeUserControlStep parentStep, WxeUserControl userControl, WxeFunction subFunction, Control sender, bool usesEventTarget) : this((WxeStep)parentStep, userControl, subFunction, sender, usesEventTarget) { }