public static void MapTerminalsInOrder(this DfirModelMap dfirModelMap, SMNode sourceModelNode, DfirNode dfirNode) { foreach (var pair in sourceModelNode.Terminals.Zip(dfirNode.Terminals)) { dfirModelMap.MapTerminalAndType(pair.Key, pair.Value); } }
public static void MapTerminalAndType( this DfirModelMap dfirModelMap, SMTerminal modelTerminal, DfirTerminal dfirTerminal) { dfirModelMap.AddMapping(modelTerminal, dfirTerminal); dfirTerminal.DataType = modelTerminal.DataType.IsUnset() ? NITypes.Void : modelTerminal.DataType; }
public FunctionMocReflector( IReflectableModel source, ReflectionCancellationToken reflectionCancellationToken, IScheduledActivityManager scheduledActivityManager, IMessageDescriptorTranslator additionalErrorTexts, Envoy buildSpecSource, SpecAndQName specAndQName, DfirModelMap map) : base(source, reflectionCancellationToken, scheduledActivityManager, additionalErrorTexts, buildSpecSource, specAndQName) { _map = map; }
public static DfirWire TranslateModelWire(this DfirModelMap dfirModelMap, SMWire wire) { var connectedDfirTerminals = new List <DfirTerminal>(); var looseEnds = new List <SMTerminal>(); foreach (SMTerminal terminal in wire.Terminals) { if (terminal.ConnectedTerminal != null) { connectedDfirTerminals.Add(dfirModelMap.GetDfirForTerminal(terminal.ConnectedTerminal)); } else { looseEnds.Add(terminal); } } var parentDiagram = (DfirDiagram)dfirModelMap.GetDfirForModel(wire.Owner); DfirWire dfirWire = DfirWire.Create(parentDiagram, connectedDfirTerminals); dfirModelMap.AddMapping(wire, dfirWire); int i = 0; // Map connected model wire terminals foreach (SMTerminal terminal in wire.Terminals.Where(t => t.ConnectedTerminal != null)) { dfirModelMap.MapTerminalAndType(terminal, dfirWire.Terminals[i]); i++; } // Map unconnected model wire terminals foreach (SMTerminal terminal in looseEnds) { DfirTerminal dfirTerminal = dfirWire.CreateBranch(); dfirModelMap.MapTerminalAndType(terminal, dfirTerminal); } // "Map" loose ends with no terminals in the model int numberOfLooseEndsInModel = wire.Joints.Count(j => j.Dangling); for (int looseEndsIndex = 0; looseEndsIndex < numberOfLooseEndsInModel; ++looseEndsIndex) { DfirTerminal dfirTerminal = dfirWire.CreateBranch(); dfirTerminal.DataType = NITypes.Void; } return(dfirWire); }
public FunctionMocReflector(MocReflector reflectorToCopy) : base(reflectorToCopy) { _map = ((FunctionMocReflector)reflectorToCopy)._map; }