GetNodeOfInstance() public method

public GetNodeOfInstance ( Wiring instance ) : Node
instance Wiring
return Node
示例#1
0
        // Enumerate all links from the outlets and cache them.
        void CacheLinks(Patch patch)
        {
            _cachedLinks = new List <NodeLink>();

            foreach (var outlet in _outlets)
            {
                // Scan all the events from the outlet.
                var boundEvent  = outlet.boundEvent;
                var targetCount = boundEvent.GetPersistentEventCount();
                for (var i = 0; i < targetCount; i++)
                {
                    var target = boundEvent.GetPersistentTarget(i);

                    // Ignore it if it's a null event or the target is not a node.
                    if (target == null || !(target is Wiring.NodeBase))
                    {
                        continue;
                    }

                    // Try to retrieve the linked inlet.
                    var targetNode = patch.GetNodeOfInstance((Wiring.NodeBase)target);
                    var methodName = boundEvent.GetPersistentMethodName(i);
                    var inlet      = targetNode.GetInletWithName(methodName);

                    // Cache it if it's a valid link.
                    if (targetNode != null && inlet != null)
                    {
                        _cachedLinks.Add(new NodeLink(this, outlet, targetNode, inlet));
                    }
                }
            }
        }
示例#2
0
文件: Node.cs 项目: keijiro/OscKlak
        // Enumerate all links from the outlets and cache them.
        void CacheLinks(Patch patch)
        {
            _cachedLinks = new List<NodeLink>();

            foreach (var outlet in _outlets)
            {
                // Scan all the events from the outlet.
                var boundEvent = outlet.boundEvent;
                var targetCount = boundEvent.GetPersistentEventCount();
                for (var i = 0; i < targetCount; i++)
                {
                    var target = boundEvent.GetPersistentTarget(i);

                    // Ignore it if it's a null event or the target is not a node.
                    if (target == null || !(target is Wiring.NodeBase)) continue;

                    // Try to retrieve the linked inlet.
                    var targetNode = patch.GetNodeOfInstance((Wiring.NodeBase)target);
                    var methodName = boundEvent.GetPersistentMethodName(i);
                    var inlet = targetNode.GetInletWithName(methodName);

                    // Cache it if it's a valid link.
                    if (targetNode != null && inlet != null)
                        _cachedLinks.Add(new NodeLink(this, outlet, targetNode, inlet));
                }
            }
        }