This document is archived and information here might be outdated.  Recommended version.


INAContextEdit.Bind Method (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference (NetworkAnalyst)  

INAContextEdit.Bind Method

Prepare the context for analysis based upon the current network dataset schema.

[Visual Basic .NET]
Public Sub Bind ( _
    ByVal pNetworkDataset As INetworkDataset, _
    ByVal pGPMessages As IGPMessages _
)
[C#]
public void Bind (
    INetworkDataset pNetworkDataset,
    IGPMessages pGPMessages
);
[C++]
HRESULT Bind(
  INetworkDataset* pNetworkDataset,
  IGPMessages* pGPMessages
);
[C++]

Parameters pNetworkDataset [in]
pNetworkDataset is a parameter of type INetworkDataset pGPMessages [in]
pGPMessages is a parameter of type IGPMessages

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server. Requires Network Analyst Extension.

Remarks

Bind attaches the NAContext to the input NetworkDataset.  This ensures the NAContext is properly initialized based on the network dataset specified.

You must call Bind after calling CreateContext on NASolver.

[C#]

This illustrates how you can create a new NAContext and bind the NetworkDataset to it.

public INAContext CreateContextAndBindToNetworkDataset(INetworkDataset networkDataset)
{
  INASolver naSolver=new NARouteSolver() as INASolver;
  IDENetworkDataset deNetworkDataset=((IDatasetComponent)networkDataset).DataElement as IDENetworkDataset;
  INAContext context=naSolver.CreateContext(deNetworkDataset, naSolver.DisplayName) as INAContext;
  INAContextEdit contextEdit=(INAContextEdit)context;
  contextEdit.Bind(networkDataset,  new GPMessagesClass());

  return context;
}   

[C++]

See Also

INAContextEdit Interface

.NET Snippets

Create Location Allocation Layer | Create Service Area Layer | Create Route Layer | Create Closest Facility Layer

.NET Samples

Closest facility solver (Code Files: frmClosestFacilitySolver) | Service area solver (Code Files: frmServiceAreaSolver) | Location-allocation solver (Code Files: frmLocationAllocationSolver) | Vehicle routing problem solver (Code Files: frmVRPSolver) | Origin-destination cost matrix solver (Code Files: frmODCostMatrixSolver)