Builds a URL that represents the state of the commands and parameters associated with a UrlManager.

Namespace:  Endeca.Web.Url
Assembly:  Endeca.Web (in Endeca.Web.dll) Version: 2.1.3.0 (2.1.3.622)

Syntax

C#
public string BuildUrl(
	Action<CommandActionInfo> action
)
Visual Basic (Declaration)
Public Function BuildUrl ( _
	action As Action(Of CommandActionInfo) _
) As String
Visual C++
public:
String^ BuildUrl(
	Action<CommandActionInfo^>^ action
)

Parameters

action
Type: System..::.Action<(Of <(CommandActionInfo>)>)
A delegate that represents the changes to make to the commands and parameters registered with a UrlManager, in order to transition to the desired state that should be encoded in the URL.

Remarks

The BuildUrl method constructs a URL by encoding the state of one or more EndecaCommand objects into a URL. The commands that are included in this encoding process are in general the commands that have been registered with the UrlManager associated with this builder. However, the exact state that is encoded typically reflects a modification (delta) from the base state of these commands.

The desired modification(s) to the command or commands is specified by the action delegate. The implementation of this delegate can request copies of the commands that have been registered with the UrlManager by calling Get<(Of <(TCommand>)>)(String), and then alter the state of these copies to reflect the desired state that should be encoded into the URL. If any commands were registered with the UrlManager but not copied by calling Get<(Of <(TCommand>)>)(String) in the action delegate, then the state of those unmodified commands is also encoded into the URL.

In addition to the state of one or more commands, the URL can include arbitrary name-value pairs. These name-value pairs are represented by the Parameters collection. Similar to the manner in which the action delegate can obtain copies of the commands registered with the UrlManager, the delegate can obtain a copy of the Parameters collection. The delegate can then alter this copy to specify the exact name-value parameters to include in the URL.

Note that the algorithm by which commands and parameters are encoded into a URL is represented by the UrlProvider associated with the UrlManager. The Construct(String, CommandInfoCollection, NameValueCollection) method of this provider is called after the action delegate is invoked to produce the URL that is returned by this method.

Examples

The following example illustrates how to construct a URL that represents a navigation state in which a particular DimensionValue has been selected:
CopyC#
public string SelectDimensionValueUrl( UrlManager mgr, DimensionValue dimVal ) 
{     
   return mgr.Urls.BuildUrl( delegate( CommandActionInfo i ) {
      // The Get method returns a copy of the command, and assumes a 
      // NavigationCommand (or NavigationDataSource) has been registered with an 
      // ID of 'navCmd'.
      i.Get<NavigationCommand>("navCmd").SelectDimensionValue( dimVal );

      // Add a name/value pair to be encoded into the URL.
      i.Parameters["Foo"] = "Bar";
   } );
}

Exceptions

ExceptionCondition
System..::.ArgumentNullExceptionif action is null.

See Also