ArcGIS Runtime SDK for WPF - Library Reference
CustomParameters Property
See Also  Example
ESRI.ArcGIS.Client.Tasks Namespace > TaskBase Class : CustomParameters Property

Gets or sets the custom parameters to be appended to the request url.

Syntax

Visual Basic (Declaration) 
Public Property CustomParameters As IDictionary(Of String,String)
C# 
public IDictionary<string,string> CustomParameters {get; set;}

Remarks

This Property allows adding string key/value argument pairs to be appended to the request Url when used by the the following Classes:

Under most circumstances, adding Tasks.TaskBase.CustomParameters is optional because typically the setting of Url key/value argument pairs is handled for you behind the scenes when you set the various properties of the 'Parameters' Class values for the task being used in the API. For example: you set the various Tasks.Query properties that are used by the Tasks.QueryTask.ExecuteAsync(ESRI.ArcGIS.Client.Tasks.Query, object) Method or you set the various Tasks.BufferParameters properties that are used by the Tasks.GeometryService.BufferAsync(ESRI.ArcGIS.Client.Tasks.BufferParameters) Method, etc.

Using the Tasks.TaskBase.CustomParameters is usually reserved for the following scenarios:

  • You need to consume a custom ArcGIS Server Object Extension (SOE). This SOE may take custom parameters that are not available as properties of a particular 'Parameter' Class in the API.
  • You need to pass a particular user token or unique application id value as part of the request Url that will be processed via some custom function on ArcGIS Server.
  • You do not want to use the provided API properties of the 'Parameters' Classes and want to manually specify the string key/value argument pairs. This option requires knowing the exact REST Url parameter value for the task being used. The following table provides a mapping to show which API 'Parameters' Class corresponds to the REST help in deciphering the Parameter values.
API 'Parameters' Class REST Help doc (showing Parameters)
Tasks.Query Query (Operation)
Tasks.RelationshipParameter Query Related Records (Operation)
Tasks.BufferParameters Buffer Geometries (Operation)
Tasks.DensifyParameters Densify (Operation)
Tasks.DistanceParameters Distance (Operation)
Tasks.GeneralizeParameters Generalize (Operation)
Tasks.OffsetParameters Offset (Operation)
Tasks.LocatorFindParameters Find Address Candidates (Operation)
Tasks.AddressToLocationsParameters Reverse Geocode (Operation)
Tasks.RouteParameters Solve Route (Operation)
Tasks.RouteClosestFacilityParameters Solve Closest Facility (Operation)
Tasks.RouteServiceAreaParameters Solve Service Area (Operation)
Tasks.ComputeHistogramsParameter Compute Histograms (Operation)
Tasks.FindParameters Find (Operation)
Tasks.GenerateRendererParameters Generate Renderer (Operation)
Tasks.GPParameter GP Service (Operation)
Tasks.IdentifyParameters Identify (Operation)
Tasks.ImageServiceIdentifyParameters Identify - Image Service (Operation)
Tasks.MensurationAreaParameter Measure - Image Service (Operation)
Tasks.MensurationPointParameter Measure - Image Service (Operation)
Tasks.MensurationLengthParameter Measure - Image Service (Operation)
Tasks.MensurationHeightParameter Measure - Image Service (Operation)
Tasks.UploadParameters Upload (Operation)

NOTE: Setting a Tasks.TaskBase.CustomParameter property value takes precedence over setting a property in one of the 'Property' Classes. For example if you specified both the Tasks.BufferParameters.Geodesic Property to be true and also specified a Tasks.TaskBase.CustomParameters of 'geodesic' to be false, the value passed in the Url of the request would be false.

The key/value pairs of the Tasks.TaskBase.CustomParameter property are case sensitive.

TIP: To see the actual string key/value argument pairs that are appended to the request Url, use an internet traffic monitoring application (like Fiddler) to view internet traffic.

Example

How to use:

Use an internet traffic monitoring application (like Fiddler) to view the Url response when you click the button. Check off the 'Use CustomParameters' checkbox and click the button again. Notice how the Url response is different.

The XAML code in this example is used in conjunction with the code-behind (C# or VB.NET) to demonstrate the functionality.

The following screen shots corresponds to the code example in this page.

Testing the use of CustomParameters on a task.

Viewing the results of using CustomParameters in Fiddler.

Viewing the results of not using CustomParameters in Fiddler.

XAMLCopy Code
<Grid x:Name="LayoutRoot" Background="Gray">
  
  <CheckBox Content="Use CustomParameters" Height="16" HorizontalAlignment="Left" Margin="12,86,0,0" Name="CheckBox1" 
            VerticalAlignment="Top" Width="158" IsChecked="True"/>
  <Button Content="Execute a QueryTask" Height="23" HorizontalAlignment="Left" Margin="12,108,0,0" Name="Button1" 
          VerticalAlignment="Top" Width="158" Click="Button1_Click"/>
    
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="73" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="788" TextWrapping="Wrap" 
   Text="Use an internet traffic monitoring application (like Fiddler) to view the Url response when you click the button.
   Check off the 'Use CustomParameters' checkbox and click the button again. Notice how the Url response is different." />
  
</Grid>
C#Copy Code
private void Button1_Click(object sender, System.Windows.RoutedEventArgs e)
{
  // Create a new QueryTask.
  ESRI.ArcGIS.Client.Tasks.QueryTask myQueryTask = null;
  myQueryTask = new ESRI.ArcGIS.Client.Tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");
  
  // Set the DisableClientCaching to true such that a unique post to the ArcGIS Server will always occur.
  myQueryTask.DisableClientCaching = true;
  
  // Define a Query. Set a couple of Properties.
  ESRI.ArcGIS.Client.Tasks.Query myQuery = new ESRI.ArcGIS.Client.Tasks.Query();
  myQuery.OutFields.Add("*");
  myQuery.Where = "1=1";
  
  if (CheckBox1.IsChecked == true)
  {
    // Use The QueryTask.CustomParameters.
    
    // Append an extra parameter.
    myQueryTask.CustomParameters["Hello"] = "World";
    
    // Override the existing Query.OutFields property with this parameter.
    myQueryTask.CustomParameters["outFields"] = "STATE_NAME";
  }
  // Invoke the QueryTask which will cause internet traffic to occur.
  myQueryTask.ExecuteAsync(myQuery); 
}
VB.NETCopy Code
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
  
  ' Create a new QueryTask.
  Dim myQueryTask As ESRI.ArcGIS.Client.Tasks.QueryTask
  myQueryTask = New ESRI.ArcGIS.Client.Tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5")
  
  ' Set the DisableClientCaching to true such that a unique post to the ArcGIS Server will always occur.
  myQueryTask.DisableClientCaching = True
  
  ' Define a Query. Set a couple of Properties.
  Dim myQuery As ESRI.ArcGIS.Client.Tasks.Query = New ESRI.ArcGIS.Client.Tasks.Query
  myQuery.OutFields.Add("*")
  myQuery.Where = "1=1"
  
  If CheckBox1.IsChecked = True Then
    
    ' Use The QueryTask.CustomParameters.
    
    ' Append an extra parameter.
    myQueryTask.CustomParameters("Hello") = "World"
    
    ' Override the existing Query.OutFields property with this parameter.
    myQueryTask.CustomParameters("outFields") = "STATE_NAME"
    
  End If
  
  ' Invoke the QueryTask which will cause internet traffic to occur.
  myQueryTask.ExecuteAsync()
  
End Sub

Requirements

Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8

See Also

© ESRI, Inc. All Rights Reserved.