/// <summary> /// Executes the specified method with the specified data modifications being used for any validations that are created, and with the default action being /// available to form controls and buttons. /// </summary> /// <param name="dataModifications"></param> /// <param name="method"></param> /// <param name="defaultActionOverride">Pass null to use the post-back corresponding to the first of the data modifications.</param> public static void ExecuteWithDataModificationsAndDefaultAction( IReadOnlyCollection <DataModification> dataModifications, Action method, NonPostBackFormAction defaultActionOverride = null) { if (dataModifications.Count == 0) { throw new ApplicationException("There must be at least one data modification."); } dataModificationAsserter(dataModifications); Current.stack.Push(Tuple.Create(defaultActionOverride, new Stack <Func <bool> >(), dataModifications)); try { method(); } finally { Current.stack.Pop(); } }
/// <summary> /// Executes the specified method with the specified data modifications being used for any validations that are created, and with the default action being /// available to form controls and buttons. /// </summary> /// <param name="dataModifications"></param> /// <param name="method"></param> /// <param name="defaultActionOverride">The default action. Pass null to use the post-back corresponding to the first of the data modifications.</param> /// <param name="formControlDefaultActionOverride">The form-control-specific default action. Pass null to use the same action for both form controls and /// buttons.</param> public static T ExecuteWithDataModificationsAndDefaultAction <T>( IEnumerable <DataModification> dataModifications, Func <T> method, NonPostBackFormAction defaultActionOverride = null, SpecifiedValue <NonPostBackFormAction> formControlDefaultActionOverride = null) { IReadOnlyCollection <DataModification> dmCollection = dataModifications.ToImmutableArray(); if (dmCollection.Count == 0) { throw new ApplicationException("There must be at least one data modification."); } dataModificationAsserter(dmCollection); Current.stack.Push((defaultActionOverride, formControlDefaultActionOverride, new Stack <Func <bool> >(), dmCollection)); try { return(method()); } finally { Current.stack.Pop(); } }