Builds a URL that represents the state of the commands and parameters associated with a UrlManager. This method accepts an action delegate that will perform actions on members of a CommandInfoCollection. Additionally, this method takes a command id and an indexed result object as parameters. Before invoking the action, this method will update the CommandInfoCollection such that the command with id equal to commandId has the provided result object. This result object must implement the IIndexProvider interface. This method is intended for use with Content Assembler Web applications and others that make use of CommandResult objects that are not associated with a data source registered with the UrlManager. This method allows for the construction of URLs using result objects not usually found in the CommandInfoCollection associated with the data sources registered to the 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,
	IIndexProvider indexProvider,
	string commandID
)
Visual Basic (Declaration)
Public Function BuildUrl ( _
	action As Action(Of CommandActionInfo), _
	indexProvider As IIndexProvider, _
	commandID As String _
) As String
Visual C++
public:
String^ BuildUrl(
	Action<CommandActionInfo^>^ action, 
	IIndexProvider^ indexProvider, 
	String^ commandID
)

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.
indexProvider
Type: Endeca.Web.Url.Indexing..::.IIndexProvider
An indexed result object that will be included in the CommandInfoCollection used by the action. The command in the CommandInfoCollection with an id equal to commandId will be updated such that the result object is equal to the indexProvider. This object must implement the IIndexProvider interface.
commandID
Type: System..::.String
A string representing the ID of the command whose result object should be updated before the action is invoked.

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";
   } , new IndexedDimensionValueCollection(dimensionValues), navigationDataSourceId );
}

Exceptions

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

See Also