public virtual void TranslateBrowsePathsToNodeIds(
OperationContext context,
BrowsePathCollection browsePaths,
out BrowsePathResultCollection results,
out DiagnosticInfoCollection diagnosticInfos)
{
if (browsePaths == null)throw new ArgumentNullException("browsePaths");
bool diagnosticsExist = false;
results = new BrowsePathResultCollection(browsePaths.Count);
diagnosticInfos = new DiagnosticInfoCollection(browsePaths.Count);
for (int ii = 0; ii < browsePaths.Count; ii++)
{
// check if request has timed out or been cancelled.
if (StatusCode.IsBad(context.OperationStatus))
{
throw new ServiceResultException(context.OperationStatus);
}
BrowsePath browsePath = browsePaths[ii];
BrowsePathResult result = new BrowsePathResult();
result.StatusCode = StatusCodes.Good;
results.Add(result);
ServiceResult error = null;
// need to trap unexpected exceptions to handle bugs in the node managers.
try
{
error = TranslateBrowsePath(context, browsePath, result);
}
catch (Exception e)
{
error = ServiceResult.Create(e, StatusCodes.BadUnexpectedError, "Unexpected error translating browse path.");
}
if (ServiceResult.IsGood(error))
{
// check for no match.
if (result.Targets.Count == 0)
{
error = StatusCodes.BadNoMatch;
}
// put a placeholder for diagnostics.
else if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
diagnosticInfos.Add(null);
}
}
// check for error.
if (error != null && error.Code != StatusCodes.Good)
{
result.StatusCode = error.StatusCode;
if ((context.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
DiagnosticInfo diagnosticInfo = ServerUtils.CreateDiagnosticInfo(m_server, context, error);
diagnosticInfos.Add(diagnosticInfo);
diagnosticsExist = true;
}
}
}
// clear the diagnostics array if no diagnostics requested or no errors occurred.
UpdateDiagnostics(context, diagnosticsExist, ref diagnosticInfos);
}