public bool ClearKnowledgeOfConnection(LLDNBase gnb) { bool any = false; foreach (ParamBase pb in this.genParams) { if (pb.type != ParamBase.Type.PCMInput) { continue; } ParamConnection pc = pb as ParamConnection; if (pc.IsConnected() == false) { continue; } if (pc.Reference == gnb) { pc.SetReference(null); any = true; } } return(any); }
public bool SetConnection(ParamConnection ownedConParam, LLDNBase newConnection) { if (ownedConParam.IsConnected() == true) { if (ownedConParam.Reference == newConnection) { return(true); } if (newConnection.HierarchyContains(this) == true) { return(false); } } ownedConParam.SetReference(newConnection); return(true); }
/// <summary> /// Clear all PCM connection parameters in the node. /// </summary> public void ClearAllConnections() { foreach (ParamBase pb in this.genParams) { if (pb.type != ParamBase.Type.PCMInput) { continue; } ParamConnection pc = pb as ParamConnection; if (pc.IsConnected() == false) { continue; } pc.SetReference(null); } }
public WiringDocument Clone(string newName) { // Fill up the directory. Used so we can use existing // cloning utilities for cloning connection params. Dictionary <string, LLDNBase> thisLookup = new Dictionary <string, LLDNBase>(); foreach (LLDNBase gnb in this.generators) { thisLookup.Add(gnb.GUID, gnb); } // Copy all the generators. Dictionary <LLDNBase, LLDNBase> thisToThatMap = new Dictionary <LLDNBase, LLDNBase>(); WiringDocument wd = new WiringDocument(false, null); foreach (LLDNBase gnb in this.generators) { LLDNBase clone = gnb.Clone(thisLookup); clone.cachedUILocation = gnb.cachedUILocation; wd.generators.Add(clone); thisToThatMap.Add(gnb, clone); } // Convert the connections to point to their own equivalents. foreach (LLDNBase gnb in wd.generators) { foreach (ParamBase pb in gnb.nodeParams) { if (pb.type == ParamBase.Type.PCMInput) { ParamConnection pcon = pb as ParamConnection; if (pcon.IsConnected() == false) { continue; } LLDNBase conv; if (thisToThatMap.TryGetValue(pcon.Reference, out conv) == true) { pcon.SetReference(conv); } else { pcon.ClearReference(); } } } } // Fix up the output if (this.output != null) { LLDNBase gbOutput = thisToThatMap[this.output]; if (gbOutput != null && gbOutput.nodeType == LLDNBase.NodeType.Output) { wd.output = (LLDNOutput)gbOutput; } } // Finish if (string.IsNullOrEmpty(newName) == false) { wd.SetName(newName); } else { wd.SetName(this.name); } return(wd); }