Example #1
0
        /// <summary>
        ///   Implements <see cref="Remotion.Web.UI.ISmartNavigablePage.GetNavigationUrlParameters">ISmartNavigablePage.GetNavigationUrlParameters</see>.
        /// </summary>
        public NameValueCollection GetNavigationUrlParameters()
        {
            NameValueCollection urlParameters = new NameValueCollection();

            foreach (INavigationControl control in _navigationControls.Values)
            {
                NameValueCollectionUtility.Append(urlParameters, control.GetNavigationUrlParameters());
            }

            return(urlParameters);
        }
        /// <summary>
        ///   Implements <see cref="IWxePage.GetPermanentUrlParameters">IWxePage.GetPermanentUrlParameters()</see>.
        /// </summary>
        public NameValueCollection GetPermanentUrlParameters()
        {
            NameValueCollection urlParameters = CurrentPageFunction.VariablesContainer.SerializeParametersForQueryString();

            ISmartNavigablePage smartNavigablePage = _page as ISmartNavigablePage;

            if (smartNavigablePage != null)
            {
                NameValueCollectionUtility.Append(urlParameters, smartNavigablePage.GetNavigationUrlParameters());
            }

            return(urlParameters);
        }
Example #3
0
        public void AppendWithEmptyCollection()
        {
            NameValueCollectionUtility.Append(_collection, new NameValueCollection());

            Assert.That(_collection.Count, Is.EqualTo(3));

            Assert.That(_collection.GetKey(0), Is.EqualTo("FirstKey"));
            Assert.That(_collection.GetKey(1), Is.EqualTo("SecondKey"));
            Assert.That(_collection.GetKey(2), Is.EqualTo("ThirdKey"));

            Assert.That(_collection["FirstKey"], Is.EqualTo("FirstValue"));
            Assert.That(_collection["SecondKey"], Is.EqualTo("SecondValue"));
            Assert.That(_collection["ThirdKey"], Is.EqualTo("ThirdValue,Other ThirdValue"));
        }
Example #4
0
        public void AppendWithOtherCollection()
        {
            NameValueCollectionUtility.Append(_collection, _otherCollection);

            Assert.That(_collection.Count, Is.EqualTo(5));

            Assert.That(_collection.GetKey(0), Is.EqualTo("FirstKey"));
            Assert.That(_collection.GetKey(1), Is.EqualTo("SecondKey"));
            Assert.That(_collection.GetKey(2), Is.EqualTo("ThirdKey"));
            Assert.That(_collection.GetKey(3), Is.EqualTo("FourthKey"));
            Assert.That(_collection.GetKey(4), Is.EqualTo("FifthKey"));

            Assert.That(_collection["FirstKey"], Is.EqualTo("FirstValue"));
            Assert.That(_collection["SecondKey"], Is.EqualTo("Other SecondValue"));
            Assert.That(_collection["ThirdKey"], Is.EqualTo("ThirdValue,Other ThirdValue"));
            Assert.That(_collection["FourthKey"], Is.EqualTo("FourthValue"));
            Assert.That(_collection["FifthKey"], Is.EqualTo("FifthValue"));
        }
Example #5
0
        /// <summary> Creates a <see cref="CommandInfo"/> for the <see cref="HrefCommand"/>. </summary>
        /// <param name="parameters">
        ///   The strings inserted into the href attribute using <c>string.Format</c>.
        /// </param>
        /// <param name="onClick">
        ///   The string always rendered in the <c>onClick</c> tag of the anchor element.
        /// </param>
        /// <param name="additionalUrlParameters">
        ///   The <see cref="NameValueCollection"/> containing additional url parameters.
        ///   Must not be <see langword="null"/>.
        /// </param>
        /// <param name="includeNavigationUrlParameters">
        ///   <see langword="true"/> to include URL parameters provided by <see cref="ISmartNavigablePage"/>.
        ///   Defaults to <see langword="true"/>.
        /// </param>
        /// <exception cref="InvalidOperationException">
        ///   If called while the <see cref="Type"/> is not set to <see cref="CommandType.Href"/>.
        /// </exception>
        protected virtual CommandInfo GetCommandInfoForHrefCommand(
            string[] parameters,
            string onClick,
            NameValueCollection additionalUrlParameters,
            bool includeNavigationUrlParameters)
        {
            ArgumentUtility.CheckNotNull("parameters", parameters);
            ArgumentUtility.CheckNotNull("additionalUrlParameters", additionalUrlParameters);
            if (Type != CommandType.Href)
            {
                throw new InvalidOperationException("Call to GetCommandInfoForHrefCommand not allowed unless Type is set to CommandType.Href.");
            }

            string href = HrefCommand.FormatHref(parameters);

            if (includeNavigationUrlParameters)
            {
                ISmartNavigablePage page = null;
                if (OwnerControl != null)
                {
                    page = OwnerControl.Page as ISmartNavigablePage;
                }

                if (page != null)
                {
                    additionalUrlParameters = additionalUrlParameters.Clone();
                    NameValueCollectionUtility.Append(additionalUrlParameters, page.GetNavigationUrlParameters());
                }
            }
            href = UrlUtility.AddParameters(href, additionalUrlParameters);
            if (OwnerControl != null)
            {
                href = OwnerControl.ResolveClientUrl(href);
            }

            return(CommandInfo.CreateForLink(
                       StringUtility.EmptyToNull(_toolTip),
                       StringUtility.EmptyToNull(_accessKey),
                       href,
                       StringUtility.EmptyToNull(HrefCommand.Target),
                       StringUtility.EmptyToNull(onClick)));
        }
Example #6
0
        /// <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));
        }