public virtual NodeMetadata GetNodeMetadata(
OperationContext context,
object targetHandle,
BrowseResultMask resultMask)
{
ServerSystemContext systemContext = m_systemContext.Copy(context);
lock (Lock)
{
// check for valid handle.
NodeHandle handle = IsHandleInNamespace(targetHandle);
if (handle == null)
{
return null;
}
// validate node.
NodeState target = ValidateNode(systemContext, handle, null);
if (target == null)
{
return null;
}
// read the attributes.
List<object> values = target.ReadAttributes(
systemContext,
Attributes.WriteMask,
Attributes.UserWriteMask,
Attributes.DataType,
Attributes.ValueRank,
Attributes.ArrayDimensions,
Attributes.AccessLevel,
Attributes.UserAccessLevel,
Attributes.EventNotifier,
Attributes.Executable,
Attributes.UserExecutable);
// construct the metadata object.
NodeMetadata metadata = new NodeMetadata(target, target.NodeId);
metadata.NodeClass = target.NodeClass;
metadata.BrowseName = target.BrowseName;
metadata.DisplayName = target.DisplayName;
if (values[0] != null && values[1] != null)
{
metadata.WriteMask = (AttributeWriteMask)(((uint)values[0]) & ((uint)values[1]));
}
metadata.DataType = (NodeId)values[2];
if (values[3] != null)
{
metadata.ValueRank = (int)values[3];
}
metadata.ArrayDimensions = (IList<uint>)values[4];
if (values[5] != null && values[6] != null)
{
metadata.AccessLevel = (byte)(((byte)values[5]) & ((byte)values[6]));
}
if (values[7] != null)
{
metadata.EventNotifier = (byte)values[7];
}
if (values[8] != null && values[9] != null)
{
metadata.Executable = (((bool)values[8]) && ((bool)values[9]));
}
// get instance references.
BaseInstanceState instance = target as BaseInstanceState;
if (instance != null)
{
metadata.TypeDefinition = instance.TypeDefinitionId;
metadata.ModellingRule = instance.ModellingRuleId;
}
// fill in the common attributes.
return metadata;
}
}