private protected virtual void ExecuteSplitBlock(WriteableSplitBlockOperation operation) { Node ParentNode = operation.ParentNode; string PropertyName = operation.PropertyName; IWriteableBlockListInner <IWriteableBrowsingBlockNodeIndex> Inner = GetInner(ParentNode, PropertyName) as IWriteableBlockListInner <IWriteableBrowsingBlockNodeIndex>; IWriteableBlockState OldBlockState = (IWriteableBlockState)Inner.BlockStateList[operation.BlockIndex]; Debug.Assert(operation.Index < OldBlockState.StateList.Count); int OldNodeCount = OldBlockState.StateList.Count; Inner.SplitBlock(operation); Stats.BlockCount++; IWriteableBlockState NewBlockState = operation.BlockState; Debug.Assert(OldBlockState.StateList.Count + NewBlockState.StateList.Count == OldNodeCount); Debug.Assert(NewBlockState.StateList.Count > 0); IReadOnlyBrowsingPatternIndex PatternIndex = NewBlockState.PatternIndex; IReadOnlyPatternState PatternState = NewBlockState.PatternState; AddState(PatternIndex, PatternState); Stats.PlaceholderNodeCount++; IReadOnlyBrowsingSourceIndex SourceIndex = NewBlockState.SourceIndex; IReadOnlySourceState SourceState = NewBlockState.SourceState; AddState(SourceIndex, SourceState); Stats.PlaceholderNodeCount++; NotifyBlockSplit(operation); }
private protected virtual void ExecuteMergeBlocks(WriteableMergeBlocksOperation operation) { Node ParentNode = operation.ParentNode; string PropertyName = operation.PropertyName; IWriteableBlockListInner <IWriteableBrowsingBlockNodeIndex> Inner = GetInner(ParentNode, PropertyName) as IWriteableBlockListInner <IWriteableBrowsingBlockNodeIndex>; int BlockIndex = operation.BlockIndex; IWriteableBlockState FirstBlockState = (IWriteableBlockState)Inner.BlockStateList[BlockIndex - 1]; IWriteableBlockState SecondBlockState = (IWriteableBlockState)Inner.BlockStateList[BlockIndex]; IReadOnlyBrowsingSourceIndex SourceIndex = FirstBlockState.SourceIndex; RemoveState(SourceIndex); Stats.PlaceholderNodeCount--; IReadOnlyBrowsingPatternIndex PatternIndex = FirstBlockState.PatternIndex; RemoveState(PatternIndex); Stats.PlaceholderNodeCount--; int OldNodeCount = FirstBlockState.StateList.Count + SecondBlockState.StateList.Count; int FirstNodeIndex = FirstBlockState.StateList.Count; Inner.MergeBlocks(operation); Stats.BlockCount--; IWriteableBlockState BlockState = (IWriteableBlockState)Inner.BlockStateList[BlockIndex - 1]; Debug.Assert(BlockState.StateList.Count == OldNodeCount); Debug.Assert(FirstNodeIndex < BlockState.StateList.Count); NotifyBlocksMerged(operation); }
/// <summary> /// Initializes a new instance of the <see cref="ReadOnlySourceState{IInner}"/> class. /// </summary> /// <param name="parentBlockState">The parent block state.</param> /// <param name="index">The index used to create the state.</param> public ReadOnlySourceState(IReadOnlyBlockState parentBlockState, IReadOnlyBrowsingSourceIndex index) : base(index) { Debug.Assert(parentBlockState != null); ParentBlockState = parentBlockState; }
private protected virtual ReadOnlyNodeStateDictionary BuildChildrenStateTable(ReadOnlyBrowseContext browseContext) { IReadOnlyNodeState State = browseContext.State; ReadOnlyInnerReadOnlyDictionary <string> InnerTable = State.InnerTable; ReadOnlyIndexCollectionReadOnlyList IndexCollectionList = browseContext.IndexCollectionList; ReadOnlyNodeStateDictionary ChildStateTable = CreateChildStateTable(); foreach (IReadOnlyIndexCollection <IReadOnlyBrowsingChildIndex> NodeIndexCollection in IndexCollectionList) { // List of indexes for this property (one for placeholder and optional node, several for lists and block lists) IReadOnlyList <IReadOnlyBrowsingChildIndex> NodeIndexList = NodeIndexCollection.NodeIndexList; string PropertyName = NodeIndexCollection.PropertyName; Debug.Assert(InnerTable.ContainsKey(PropertyName)); IReadOnlyInner <IReadOnlyBrowsingChildIndex> Inner = (IReadOnlyInner <IReadOnlyBrowsingChildIndex>)InnerTable[PropertyName]; for (int i = 0; i < NodeIndexList.Count; i++) { IReadOnlyBrowsingChildIndex ChildIndex = NodeIndexList[i]; // If the inner is that of a block list, and the index is for the first node in the block, add block-specific states if (Inner is IReadOnlyBlockListInner <IReadOnlyBrowsingBlockNodeIndex> AsBlockListInner && ChildIndex is IReadOnlyBrowsingNewBlockNodeIndex AsNewBlockIndex) { IReadOnlyBlockState BlockState = AsBlockListInner.InitNewBlock(AsNewBlockIndex); ((IReadOnlyBlockState <IReadOnlyInner <IReadOnlyBrowsingChildIndex> >)BlockState).InitBlockState(); Stats.BlockCount++; IReadOnlyBrowsingPatternIndex PatternIndex = BlockState.PatternIndex; IReadOnlyPatternState PatternState = BlockState.PatternState; AddState(PatternIndex, PatternState); Stats.PlaceholderNodeCount++; IReadOnlyBrowsingSourceIndex SourceIndex = BlockState.SourceIndex; IReadOnlySourceState SourceState = BlockState.SourceState; AddState(SourceIndex, SourceState); Stats.PlaceholderNodeCount++; ChildIndex = AsNewBlockIndex.ToExistingBlockIndex(); } IReadOnlyNodeState ChildState = BuildChildState(Inner, ChildIndex); ChildStateTable.Add(NodeIndexList[i], ChildState); } } return(ChildStateTable); }
/// <summary> /// Creates a IxxxSourceState object. /// </summary> private protected override IReadOnlySourceState CreateSourceState(IReadOnlyBrowsingSourceIndex sourceIndex) { ControllerTools.AssertNoOverride(this, Type.FromTypeof <FocusBlockState <IInner> >()); return(new FocusSourceState <IInner>(this, (IFocusBrowsingSourceIndex)sourceIndex)); }
/// <summary> /// Creates a IxxxSourceState object. /// </summary> private protected virtual IReadOnlySourceState CreateSourceState(IReadOnlyBrowsingSourceIndex sourceIndex) { ControllerTools.AssertNoOverride(this, typeof(ReadOnlyBlockState <IInner>)); return(new ReadOnlySourceState <IInner>(this, sourceIndex)); }
/// <summary> /// Creates a IxxxSourceState object. /// </summary> private protected override IReadOnlySourceState CreateSourceState(IReadOnlyBrowsingSourceIndex sourceIndex) { ControllerTools.AssertNoOverride(this, typeof(LayoutBlockState <IInner>)); return(new LayoutSourceState <IInner>(this, (ILayoutBrowsingSourceIndex)sourceIndex)); }
/// <summary> /// Initializes a new instance of the <see cref="ReadOnlySourceState{IInner}"/> class. /// </summary> /// <param name="parentBlockState">The parent block state.</param> /// <param name="index">The index used to create the state.</param> public ReadOnlySourceState(IReadOnlyBlockState parentBlockState, IReadOnlyBrowsingSourceIndex index) : base(index) { ParentBlockState = parentBlockState; }