示例#1
0
 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);
     }
 }
示例#2
0
 public static void MapTerminalAndType(
     this DfirModelMap dfirModelMap,
     SMTerminal modelTerminal,
     DfirTerminal dfirTerminal)
 {
     dfirModelMap.AddMapping(modelTerminal, dfirTerminal);
     dfirTerminal.DataType = modelTerminal.DataType.IsUnset() ? NITypes.Void : modelTerminal.DataType;
 }
示例#3
0
 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;
 }
示例#4
0
        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);
        }
示例#5
0
 public FunctionMocReflector(MocReflector reflectorToCopy) : base(reflectorToCopy)
 {
     _map = ((FunctionMocReflector)reflectorToCopy)._map;
 }