Exemple #1
0
        private void AddNewCase()
        {
            // Copied from CaseStructure
            NestedDiagram newDiagram = CreateNestedDiagram();

            var existingDiagram = NestedDiagrams.FirstOrDefault();

            if (existingDiagram != null)
            {
                newDiagram.Bounds = existingDiagram.Bounds;
            }
            else
            {
                // EnsureView will resize all nested diagrams to whatever the current size of the structure is.
                EnsureView(EnsureViewHints.Bounds);
            }

            AddComponent(newDiagram);

            foreach (BorderNode borderNode in BorderNodes)
            {
                if (borderNode.GetPrimaryTerminal(newDiagram) == null)
                {
                    var newTerminal = borderNode.MakePrimaryInnerTerminal(newDiagram);
                    var oldTerminal = borderNode.InnerTerminals.FirstOrDefault(t => t != newTerminal);
                    if (oldTerminal != null)
                    {
                        newTerminal.Hotspot = oldTerminal.Hotspot;
                    }
                }
            }
        }
Exemple #2
0
        private void UpdateCasesFromDataType(NIType type)
        {
            if (!type.IsUnion())
            {
                return;
            }

            NIType[] unionFields     = type.GetFields().ToArray();
            int      unionFieldCount = unionFields.Length;

            if (!NestedDiagrams.HasExactly(unionFieldCount))
            {
                while (NestedDiagrams.Count() > unionFieldCount)
                {
                    RemoveNestedDiagram((VariantMatchStructureDiagram)NestedDiagrams.Last());
                }
                while (NestedDiagrams.Count() < unionFieldCount)
                {
                    AddNewCase();
                }
            }
        }
Exemple #3
0
 /// <inheritdoc />
 protected override void Initialize(IElementCreateInfo info)
 {
     base.Initialize(info);
     if (info.ForParse)
     {
         string fixupName = nameof(FixupLoop);
         info.FixupRegistrar.RegisterPostParseFixup(this, FixupLoop, fixupName);
         info.FixupRegistrar.AddPostParseFixupOrder(IdReferenceBaseSerializer.IdReferenceFixupName, fixupName);
     }
     else
     {
         var loopConditionTunnel         = MakeTunnel <LoopConditionTunnel>(NestedDiagram, NestedDiagrams.First());
         var loopTerminateLifetimeTunnel = MakeTunnel <LoopTerminateLifetimeTunnel>(NestedDiagram, NestedDiagrams.First());
         loopConditionTunnel.TerminateLifetimeTunnel     = loopTerminateLifetimeTunnel;
         loopTerminateLifetimeTunnel.BeginLifetimeTunnel = loopConditionTunnel;
     }
 }