Opc.Ua.Server.BaseTypeSource.OnBeforeCreate C# (CSharp) Method

OnBeforeCreate() protected method

Initializes the type before creating it.
protected OnBeforeCreate ( object configuration ) : object
configuration object
return object
        protected override object OnBeforeCreate(object configuration)
        {
            // check the base type.
            ILocalNode baseType = NodeManager.GetLocalNode(m_baseTypeId);

            if (baseType == null)
            {
                throw ServiceResultException.Create(
                    StatusCodes.BadNodeIdUnknown, 
                    "The specified base type does not exist: {0}",
                    m_baseTypeId);
            }

            // check the node class.
            if (baseType.NodeClass != NodeClass)
            {
                throw ServiceResultException.Create(
                    StatusCodes.BadNodeIdRejected, 
                    "The specified base type is not a {1}: {0}",
                    baseType,
                    NodeClass);
            }

            // set the attributes to the default from the type.
            UpdateAttributes(baseType);
            
            return base.OnBeforeCreate(configuration);
        }