Opc.Ua.Server.CoreNodeManager.RegisterSource C# (CSharp) Method

RegisterSource() public method

Registers a source for a node.
The source could be one or more of IDataSource, IEventSource, ICallable, IHistorian or IViewManager
public RegisterSource ( NodeId nodeId, object source, object handle, bool isEventSource ) : void
nodeId NodeId
source object
handle object
isEventSource bool
return void
        public void RegisterSource(NodeId nodeId, object source, object handle, bool isEventSource)
        {
            if (nodeId == null) throw new ArgumentNullException("nodeId");
            if (source == null) throw new ArgumentNullException("source");
            
            #if LEGACY_CORENODEMANAGER
            try
            {
                m_lock.Enter();

                ILocalNode node = GetManagerHandle(nodeId) as ILocalNode;

                if (node == null)
                {
                    throw new ServiceResultException(StatusCodes.BadNodeIdInvalid);
                }

                if (isEventSource)
                {
                    IEventSource eventSource = source as IEventSource;

                    if (eventSource != null)
                    {
                        m_eventSources[source] = eventSource;
                    }
                }

                // remove existing handle.
                SourceHandle existingHandle = node.Handle as SourceHandle;

                if (existingHandle != null)
                {
                    UnregisterSource(existingHandle.Source);
                }
                
                // add a new handle.
                if (source != null)
                {
                    node.Handle = new SourceHandle(source, handle);
                }
                else
                {
                    node.Handle = null;
                }
            }
            finally
            {
                m_lock.Exit();
            }
            #endif
        }