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 Route Layer | Create Service Area Layer | Create Closest Facility Layer | Create Location Allocation 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)