/// <summary></summary>
        protected override void AddNextNodeToCycle(IFocusCyclableNodeState state)
        {
            FocusInsertionChildNodeIndexList CycleIndexList = state.CycleIndexList;
            Node          ParentNode = state.ParentState.Node;
            IFocusIndex   NodeIndex  = state.ParentIndex;
            CycleBodyInfo Info       = new();

            List <Type> BodyTypeList = new List <Type>()
            {
                Type.FromTypeof <EffectiveBody>(), Type.FromTypeof <DeferredBody>(), Type.FromTypeof <ExternBody>(), Type.FromTypeof <PrecursorBody>()
            };

            foreach (IFocusInsertionChildNodeIndex Index in CycleIndexList)
            {
                Body Body = (Body)Index.Node;

                if (BodyTypeList.Contains(Type.FromGetType(Body)))
                {
                    BodyTypeList.Remove(Type.FromGetType(Body));
                }

                Info.Update(Body);
            }

            // If the list is full, no need to add more nodes to the cycle.
            if (BodyTypeList.Count > 0)
            {
                Type NodeType = BodyTypeList[0];
                Node NewBody  = NodeHelper.CreateInitializedBody(NodeType, Info.Documentation, Info.RequireBlocks, Info.EnsureBlocks, Info.ExceptionIdentifierBlocks, Info.EntityDeclarationBlocks, Info.BodyInstructionBlocks, Info.ExceptionHandlerBlocks, Info.AncestorType);

                IFocusBrowsingInsertableIndex InsertableNodeIndex = NodeIndex as IFocusBrowsingInsertableIndex;
                Debug.Assert(InsertableNodeIndex != null);
                IFocusInsertionChildNodeIndex InsertionIndex = InsertableNodeIndex.ToInsertionIndex(ParentNode, NewBody) as IFocusInsertionChildNodeIndex;
                Debug.Assert(InsertionIndex != null);

                CycleIndexList.Add(InsertionIndex);
            }
        }
Exemple #2
0
        /// <summary></summary>
        protected override void AddNextNodeToCycle(IFocusCyclableNodeState state)
        {
            IFocusInsertionChildNodeIndexList CycleIndexList = state.CycleIndexList;
            INode       ParentNode = state.ParentState.Node;
            IFocusIndex NodeIndex  = state.ParentIndex;

            IDocument Documentation = null;
            IBlockList <IAssertion, Assertion>   RequireBlocks                         = null;
            IBlockList <IAssertion, Assertion>   EnsureBlocks                          = null;
            IBlockList <IIdentifier, Identifier> ExceptionIdentifierBlocks             = null;
            IBlockList <IEntityDeclaration, EntityDeclaration> EntityDeclarationBlocks = null;
            IBlockList <IInstruction, Instruction>             BodyInstructionBlocks   = null;
            IBlockList <IExceptionHandler, ExceptionHandler>   ExceptionHandlerBlocks  = null;
            IOptionalReference <IObjectType> AncestorType = null;

            List <Type> BodyTypeList = new List <Type>()
            {
                typeof(EffectiveBody), typeof(DeferredBody), typeof(ExternBody), typeof(PrecursorBody)
            };

            foreach (IFocusInsertionChildNodeIndex Index in CycleIndexList)
            {
                IBody Body = Index.Node as IBody;
                Debug.Assert(Body != null);

                if (BodyTypeList.Contains(Body.GetType()))
                {
                    BodyTypeList.Remove(Body.GetType());
                }

                switch (Body)
                {
                case IEffectiveBody AsEffective:
                    Documentation             = AsEffective.Documentation;
                    RequireBlocks             = AsEffective.RequireBlocks;
                    EnsureBlocks              = AsEffective.EnsureBlocks;
                    ExceptionIdentifierBlocks = AsEffective.ExceptionIdentifierBlocks;
                    EntityDeclarationBlocks   = AsEffective.EntityDeclarationBlocks;
                    BodyInstructionBlocks     = AsEffective.BodyInstructionBlocks;
                    ExceptionHandlerBlocks    = AsEffective.ExceptionHandlerBlocks;
                    break;

                case IDeferredBody AsDeferred:
                    Documentation             = AsDeferred.Documentation;
                    RequireBlocks             = AsDeferred.RequireBlocks;
                    EnsureBlocks              = AsDeferred.EnsureBlocks;
                    ExceptionIdentifierBlocks = AsDeferred.ExceptionIdentifierBlocks;
                    break;

                case IExternBody AsExtern:
                    Documentation             = AsExtern.Documentation;
                    RequireBlocks             = AsExtern.RequireBlocks;
                    EnsureBlocks              = AsExtern.EnsureBlocks;
                    ExceptionIdentifierBlocks = AsExtern.ExceptionIdentifierBlocks;
                    break;

                case IPrecursorBody AsPrecursor:
                    Documentation             = AsPrecursor.Documentation;
                    RequireBlocks             = AsPrecursor.RequireBlocks;
                    EnsureBlocks              = AsPrecursor.EnsureBlocks;
                    ExceptionIdentifierBlocks = AsPrecursor.ExceptionIdentifierBlocks;
                    AncestorType              = AsPrecursor.AncestorType;
                    break;
                }
            }

            // If the list is full, no need to add more nodes to the cycle.
            if (BodyTypeList.Count > 0)
            {
                Type NodeType = BodyTypeList[0];

                INode NewBody = NodeHelper.CreateInitializedBody(NodeType, Documentation, RequireBlocks, EnsureBlocks, ExceptionIdentifierBlocks, EntityDeclarationBlocks, BodyInstructionBlocks, ExceptionHandlerBlocks, AncestorType);

                IFocusBrowsingInsertableIndex InsertableNodeIndex = NodeIndex as IFocusBrowsingInsertableIndex;
                Debug.Assert(InsertableNodeIndex != null);
                IFocusInsertionChildNodeIndex InsertionIndex = InsertableNodeIndex.ToInsertionIndex(ParentNode, NewBody) as IFocusInsertionChildNodeIndex;
                Debug.Assert(InsertionIndex != null);

                CycleIndexList.Add(InsertionIndex);
            }
        }