Example #1
0
        public void Disconnect(NodeSet set, NodeHandle source, OutputPortID sourcePort, NodeHandle destination, InputPortID destinationPort)
        {
            var srcNodeFunc  = set.GetDefinition(source);
            var destNodeFunc = set.GetDefinition(destination);

            var srcNodeDSL  = set.GetDefinition(source) as TDSLInterface;
            var destNodeDSL = set.GetDefinition(destination) as TDSLInterface;

            if (srcNodeDSL == null || destNodeDSL == null)
            {
                throw new InvalidCastException();
            }

            Disconnect(
                new ConnectionInfo
            {
                Handle       = source,
                Interface    = srcNodeDSL,
                DSLPortIndex = GetDSLPortIndex(
                    sourcePort,
                    srcNodeFunc.GetPortDescription(source).Outputs.Cast <PortDescription.IPort <OutputPortID> >()
                    )
            },
                new ConnectionInfo
            {
                Handle       = destination,
                Interface    = destNodeDSL,
                DSLPortIndex = GetDSLPortIndex(
                    destinationPort,
                    destNodeFunc.GetPortDescription(destination).Inputs.Cast <PortDescription.IPort <InputPortID> >()
                    )
            });
        }
        public int FindOutputDataPortNumber(OutputPortID port)
        {
            for (int p = 0; p < Outputs.Count; ++p)
            {
                if (Outputs[p].PortNumber == port)
                {
                    return(p);
                }
            }

            throw new InternalException("Matching output port not found");
        }
        public void Disconnect <TTask>(
            NodeHandle sourceHandle,
            OutputPortID sourcePort,
            NodeInterfaceLink <TTask> destHandle
            )
            where TTask : ITaskPort <TTask>
        {
            var f = GetDefinition(destHandle);

            if (f is TTask task)
            {
                Disconnect(sourceHandle, sourcePort, destHandle, task.GetPort(destHandle));
            }
            else
            {
                throw new InvalidOperationException(
                          $"Cannot disconnect source from destination. Destination not of type {typeof(TTask).Name}");
            }
        }
 public ref /*readonly */ OutputDeclaration FindOutputDataPort(OutputPortID port)
 => ref Outputs[FindOutputDataPortNumber(port)];
 public OutputDeclaration(SimpleType typeOrElement, int patchOffset, OutputPortID portNumber)
 {
     ElementOrType = typeOrElement;
     PatchOffset   = patchOffset;
     PortNumber    = portNumber;
 }
Example #6
0
 public static Unchecked Output(OutputPortID originPortID, NodeHandle replacement, OutputPortID replacedPortID)
 {
     return(new Unchecked(false, originPortID.Port, replacement, replacedPortID.Storage));
 }
Example #7
0
 void CommonChecks <TDefinition>(NodeHandle replacedNode, OutputPortID originPort)
     where TDefinition : NodeDefinition
 {
     CommonChecks <TDefinition>(replacedNode, false, originPort.Storage.DFGPortIndex);
 }