I'm trying to query a route for pedestrians using the ArcGIS Runtime SDK for .NET 100.2.0 and the ESRI World Routing service.
First I'm retreiving the supported travel modes using the travel modes service using a GeoprocessingTask. I'm about to parse the returned modes to find the "walking" mode, what works fine so far.
When I'm getting to parse and write the AttributeParameterValues for the travel mode object, I'm running into an exception when trying to set the ParameterValue-property of it:
<SPAN class="keyword token">foreach</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">var</SPAN> attributeValue <SPAN class="keyword token">in</SPAN> modes<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"attributeParameterValues"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">string</SPAN> aName <SPAN class="operator token">=</SPAN> Convert<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToString</SPAN><SPAN class="punctuation token">(</SPAN>attributeValue<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"attributeName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">string</SPAN> pName <SPAN class="operator token">=</SPAN> Convert<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToString</SPAN><SPAN class="punctuation token">(</SPAN>attributeValue<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"parameterName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">string</SPAN> pValue <SPAN class="operator token">=</SPAN> Convert<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToString</SPAN><SPAN class="punctuation token">(</SPAN>attributeValue<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"value"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
AttributeParameterValue attr <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">AttributeParameterValue</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
attr<SPAN class="punctuation token">.</SPAN>AttributeName <SPAN class="operator token">=</SPAN> aName<SPAN class="punctuation token">;</SPAN>
attr<SPAN class="punctuation token">.</SPAN>ParameterName <SPAN class="operator token">=</SPAN> pName<SPAN class="punctuation token">;</SPAN>
attr<SPAN class="punctuation token">.</SPAN>ParameterValue <SPAN class="operator token">=</SPAN> pValue<SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// <-- here the exception occurs</SPAN>
travelMode<SPAN class="punctuation token">.</SPAN>AttributeParameterValues<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Add</SPAN><SPAN class="punctuation token">(</SPAN>attr<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>The value of "pValue" is a simple, unmodified string directly received from the above mentioned travel modes service (that reads e.g. "AVOID_MEDIUM"). Neither setting the value directly works.
I get an exception, stating that the value does not seem to conform to an expected type:
Invalid argument: Invalid element type.<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
The stacktrace reads as follows:
bei Esri.ArcGISRuntime.ArcGISException.HandleCoreError(CoreError error, Boolean throwException)
bei RuntimeCoreNet.GeneratedWrappers.Interop.CheckError(IntPtr errorHandle, Boolean throwOnFailure, GCHandle wrapperHandle)
bei RuntimeCoreNet.GeneratedWrappers.CoreAttributeParameterValue.set_ParameterValue(CoreElement value)
bei My.RoutingManager.<SetupTravelModeRouteParameters>d__20.MoveNext() in C:\source\RoutingManager.cs:Line 231.<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
The exception occurs for all of the various received values targeted to be set. Unfortunately the documentation does not provide any more information (the property itself being declared) about what type of value is expected for that part of the AttributeParameterValue. What kind of type do I need to set for "ParameterValue"?