Exemplo n.º 1
0
        /// <summary>
        /// Reduces an existing node. Opposite of Expand.
        /// </summary>
        /// <param name="reducedIndex">Index of the reduced node.</param>
        /// <param name="isChanged">True upon return if the node was changed. False if the node was already reduced.</param>
        public virtual void Reduce(IWriteableNodeIndex reducedIndex, out bool isChanged)
        {
            Contract.RequireNotNull(reducedIndex, out IWriteableNodeIndex ReducedIndex);
            Debug.Assert(StateTable.ContainsKey(ReducedIndex));
            Debug.Assert(StateTable[ReducedIndex] is IWriteablePlaceholderNodeState);

            WriteableOperationList OperationList = CreateOperationList();

            Reduce(ReducedIndex, OperationList, isNested: false);

            if (OperationList.Count > 0)
            {
                WriteableOperationReadOnlyList OperationReadOnlyList = OperationList.ToReadOnly();
                WriteableOperationGroup        OperationGroup        = CreateOperationGroup(OperationReadOnlyList, null);

                SetLastOperation(OperationGroup);
                CheckInvariant();

                isChanged = true;
            }
            else
            {
                isChanged = false;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Expands an existing node. In the node:
        /// * All optional children are assigned if they aren't
        /// * If the node is a feature call, with no arguments, an empty argument is inserted.
        /// </summary>
        /// <param name="expandedIndex">Index of the expanded node.</param>
        /// <param name="isChanged">True upon return if the node was changed. False if the node was already expanded.</param>
        public virtual void Expand(IWriteableNodeIndex expandedIndex, out bool isChanged)
        {
            Contract.RequireNotNull(expandedIndex, out IWriteableNodeIndex ExpandedIndex);
            Debug.Assert(StateTable.ContainsKey(ExpandedIndex));
            Debug.Assert(StateTable[ExpandedIndex] is IWriteablePlaceholderNodeState);

            WriteableOperationList OperationList = CreateOperationList();

            DebugObjects.AddReference(OperationList);

            Expand(ExpandedIndex, OperationList);

            if (OperationList.Count > 0)
            {
                WriteableOperationReadOnlyList OperationReadOnlyList = OperationList.ToReadOnly();
                WriteableOperationGroup        OperationGroup        = CreateOperationGroup(OperationReadOnlyList, null);

                SetLastOperation(OperationGroup);
                CheckInvariant();

                isChanged = true;
            }
            else
            {
                isChanged = false;
            }
        }
Exemplo n.º 3
0
        private protected virtual void Canonicalize(IWriteableNodeState state, WriteableOperationList operationList)
        {
            IWriteableNodeIndex NodeIndex = state.ParentIndex as IWriteableNodeIndex;

            Debug.Assert(NodeIndex != null);

            CanonicalizeChildren(state, operationList);

            Reduce(NodeIndex, operationList, isNested: state != RootState);
        }
Exemplo n.º 4
0
        private protected virtual void Expand(IWriteableNodeIndex expandedIndex, WriteableOperationList operationList)
        {
            IWriteablePlaceholderNodeState State = StateTable[expandedIndex] as IWriteablePlaceholderNodeState;

            State = FindBestExpandReduceState(State);
            Debug.Assert(State != null);

            WriteableInnerReadOnlyDictionary <string> InnerTable = State.InnerTable;

            foreach (string Key in InnerTable.Keys)
            {
                IWriteableInner Value = (IWriteableInner)InnerTable[Key];

                if (Value is IWriteableOptionalInner <IWriteableBrowsingOptionalNodeIndex> AsOptionalInner)
                {
                    ExpandOptional(AsOptionalInner, operationList);
                }
                else if (Value is IWriteableBlockListInner <IWriteableBrowsingBlockNodeIndex> AsBlockListInner)
                {
                    ExpandBlockList(AsBlockListInner, operationList);
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WriteablePlaceholderNodeState{IInner}"/> class.
 /// </summary>
 /// <param name="parentIndex">The index used to create the state.</param>
 public WriteablePlaceholderNodeState(IWriteableNodeIndex parentIndex)
     : base(parentIndex)
 {
 }