/// <summary> Executes the <see cref="WxeFunction"/> defined by the <see cref="WxeFunctionCommandInfo"/>. </summary> /// <param name="wxePage"> /// The <see cref="IWxePage"/> where this command is rendered on. Must not be <see langword="null"/>. /// </param> /// <param name="additionalWxeParameters"> /// The parameters passed to the <see cref="WxeFunction"/> in addition to the executing function's variables. /// Use <see langword="null"/> or an empty collection if all parameters are supplied by the /// <see cref="WxeFunctionCommandInfo.Parameters"/> string and the function stack. /// </param> /// <exception cref="InvalidOperationException"> /// <para> /// Thrown if called while the <see cref="Type"/> is not set to <see cref="CommandType.WxeFunction"/>. /// </para><para> /// Thrown if neither the <see cref="WxeFunctionCommandInfo.MappingID"/> nor the /// <see cref="WxeFunctionCommandInfo.TypeName"/> are set. /// </para><para> /// Thrown if the <see cref="WxeFunctionCommandInfo.MappingID"/> and <see cref="WxeFunctionCommandInfo.TypeName"/> /// specify different functions. /// </para> /// </exception> public virtual void ExecuteWxeFunction(IWxePage wxePage, NameObjectCollection additionalWxeParameters) { ArgumentUtility.CheckNotNull("wxePage", wxePage); if (Type != CommandType.WxeFunction) { throw new InvalidOperationException("Call to ExecuteWxeFunction not allowed unless Type is set to CommandType.WxeFunction."); } if (!wxePage.IsReturningPostBack) { string target = WxeFunctionCommand.Target; bool hasTarget = !string.IsNullOrEmpty(target); WxeFunction function = WxeFunctionCommand.InitializeFunction(additionalWxeParameters); IWxeCallArguments callArguments; if (hasTarget) { callArguments = new WxeCallArguments((Control)OwnerControl, new WxeCallOptionsExternal(target, null, false)); } else { callArguments = WxeCallArguments.Default; } try { wxePage.ExecuteFunction(function, callArguments); } catch (WxeCallExternalException) { } } }
private bool HasAccessForWxeFunctionCommand() { if (_wxeSecurityAdapter == null) { return(true); } return(_wxeSecurityAdapter.HasStatelessAccess(WxeFunctionCommand.ResolveFunctionType())); }
/// <summary> /// Gets the permanent URL for the <see cref="WxeFunction"/> defined by the /// <see cref="Command.WxeFunctionCommandInfo"/>. /// </summary> /// <param name="additionalUrlParameters"> /// The <see cref="NameValueCollection"/> containing additional url parameters. /// Must not be <see langword="null"/>. /// </param> /// <exception cref="InvalidOperationException"> /// <para> /// Thrown if called while the <see cref="Type"/> is not set to <see cref="CommandType.WxeFunction"/>. /// </para><para> /// Thrown if neither the <see cref="Command.WxeFunctionCommandInfo.MappingID"/> nor the /// <see cref="Command.WxeFunctionCommandInfo.TypeName"/> are set. /// </para><para> /// Thrown if the <see cref="Command.WxeFunctionCommandInfo.MappingID"/> and /// <see cref="Command.WxeFunctionCommandInfo.TypeName"/> specify different functions. /// </para> /// </exception> public virtual string GetWxeFunctionPermanentUrl(NameValueCollection additionalUrlParameters) { ArgumentUtility.CheckNotNull("additionalUrlParameters", additionalUrlParameters); if (Type != CommandType.WxeFunction) { throw new InvalidOperationException("Call to ExecuteWxeFunction not allowed unless Type is set to CommandType.WxeFunction."); } Type functionType = WxeFunctionCommand.ResolveFunctionType(); WxeParameterDeclaration[] parameterDeclarations = WxeVariablesContainer.GetParameterDeclarations(functionType); object[] parameterValues = WxeVariablesContainer.ParseActualParameters( parameterDeclarations, WxeFunctionCommand.Parameters, CultureInfo.InvariantCulture); NameValueCollection queryString = WxeVariablesContainer.SerializeParametersForQueryString(parameterDeclarations, parameterValues); queryString.Set(WxeHandler.Parameters.WxeReturnToSelf, true.ToString()); NameValueCollectionUtility.Append(queryString, additionalUrlParameters); return(WxeContext.GetPermanentUrl(new HttpContextWrapper(HttpContext.Current), functionType, queryString)); }