public void ReadDisplayName(
IList<NodeId> nodeIds,
out List<string> displayNames,
out List<ServiceResult> errors)
{
displayNames = new List<string>();
errors = new List<ServiceResult>();
// build list of values to read.
ReadValueIdCollection valuesToRead = new ReadValueIdCollection();
for (int ii = 0; ii < nodeIds.Count; ii++)
{
ReadValueId valueToRead = new ReadValueId();
valueToRead.NodeId = nodeIds[ii];
valueToRead.AttributeId = Attributes.DisplayName;
valueToRead.IndexRange = null;
valueToRead.DataEncoding = null;
valuesToRead.Add(valueToRead);
}
// read the values.
DataValueCollection results = null;
DiagnosticInfoCollection diagnosticInfos = null;
ResponseHeader responseHeader = Read(
null,
Int32.MaxValue,
TimestampsToReturn.Both,
valuesToRead,
out results,
out diagnosticInfos);
// verify that the server returned the correct number of results.
ClientBase.ValidateResponse(results, valuesToRead);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, valuesToRead);
for (int ii = 0; ii < nodeIds.Count; ii++)
{
displayNames.Add(String.Empty);
errors.Add(ServiceResult.Good);
// process any diagnostics associated with bad or uncertain data.
if (StatusCode.IsNotGood(results[ii].StatusCode))
{
errors[ii] = new ServiceResult(results[ii].StatusCode, ii, diagnosticInfos, responseHeader.StringTable);
continue;
}
// extract the name.
LocalizedText displayName = results[ii].GetValue<LocalizedText>(null);
if (!LocalizedText.IsNullOrEmpty(displayName))
{
displayNames[ii] = displayName.Text;
}
}
}