Helper object to assist server object extension developers.
Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server. Requires Network Analyst Extension.
[C#]
private IServerObjectHelper serverObjectHelper;
private INALayer2 naLayer;
public void Init(IServerObjectHelper pSOH)
{
serverObjectHelper = pSOH;
}
public void Construct(IPropertySet props)
{
// In Construct of the SOE, get a reference to the NALayer in the Map named "MyRouteLayer"
IMapServer ms = (IMapServer)this.serverObjectHelper.ServerObject;
INASOEHelper naSOEHelper = new NASOEHelperClass();
naLayer = (INALayer2)naSOEHelper.CreateNALayer(this.ms, ms.DefaultMapName, "MyRouteLayer");
}
private byte[] MySOEOperationHandler(
NameValueCollection boundVariables,
JsonObject operationInput,
string outputFormat,
string requestProperties,
out string responseProperties)
{
// In the operation, make use of the NALayer to either just get the NAContext
// or create a new NAContext that you can populate, solve, and then throw away
// to keep the state of the original NAContext pristine.
// Do this to use the existing NAContext (Make sure to reset it's state after use)
INAContext naContext = naLayer.Context;
// Do this to create a new NAContext so the state of the original NAContext doesn't get modified
INAContext naContext = naLayer.CopyContext();
PopulateStuffOnTheNAContext(naContext);
return SolveAndReturnResults(naContext);
}