protected override object OnBeforeCreate(object configuration)
{
// determine the node class for the type definition.
NodeClass typeClass = NodeClass.Method;
if (NodeClass == NodeClass.Object)
{
typeClass = NodeClass.ObjectType;
}
else if (NodeClass == NodeClass.Variable)
{
typeClass = NodeClass.VariableType;
}
// read and validate the type definition.
if (typeClass != NodeClass.Method)
{
ILocalNode typeDefinition = NodeManager.GetLocalNode(m_typeDefinitionId);
if (typeDefinition == null)
{
throw ServiceResultException.Create(
StatusCodes.BadNodeIdUnknown,
"The specified type definition does not exist: {0}",
m_typeDefinitionId);
}
// check the node class.
if (typeDefinition.NodeClass != typeClass)
{
throw ServiceResultException.Create(
StatusCodes.BadNodeIdRejected,
"The specified type definition is not a {1}: {0}",
typeDefinition,
typeClass);
}
}
return base.OnBeforeCreate(configuration);
}