Exemplo n.º 1
0
        /// <summary>
        /// Checks if a index collection is contained is a list of index collection.
        /// . Properties must be different.
        /// . They must not share an index.
        /// </summary>
        /// <param name="collection">The collection to check.</param>
        /// <param name="collectionList">The list of collections already accumulated.</param>
        public static bool IsCollectionSeparate(IReadOnlyIndexCollection collection, ReadOnlyIndexCollectionReadOnlyList collectionList)
        {
            bool Result = true;

            foreach (IReadOnlyBrowsingChildIndex Index0 in collection.NodeIndexList)
            {
                foreach (IReadOnlyIndexCollection Item in collectionList)
                {
                    if (Item.PropertyName == collection.PropertyName)
                    {
                        Result = false;
                    }

                    foreach (IReadOnlyBrowsingChildIndex Index1 in Item.NodeIndexList)
                    {
                        if (Index0.Equals(Index1))
                        {
                            Result = false;
                        }
                    }
                }
            }

            return(Result);
        }
Exemplo n.º 2
0
        public virtual void CheckConsistency()
        {
            ReadOnlyIndexCollectionList         InternalList = InternalIndexCollectionList;
            ReadOnlyIndexCollectionReadOnlyList PublicList   = IndexCollectionList;

            for (int i = 0; i < InternalList.Count; i++)
            {
                IReadOnlyIndexCollection InternalItem = InternalList[i];
                Debug.Assert(PublicList.Contains(InternalItem));
                Debug.Assert(PublicList.IndexOf(InternalItem) >= 0);

                IReadOnlyIndexCollection PublicItem = PublicList[i];
                Debug.Assert(InternalList.Contains(PublicItem));
                Debug.Assert(InternalList.IndexOf(PublicItem) >= 0);

                if (i == 0)
                {
                    Debug.Assert(!((ICollection <IReadOnlyIndexCollection>)InternalList).IsReadOnly);

                    InternalList.Remove(InternalItem);
                    InternalList.Insert(0, InternalItem);

                    IEnumerable <IReadOnlyIndexCollection> AsEnumerable = InternalList;
                    foreach (IReadOnlyIndexCollection Item in AsEnumerable)
                    {
                        Debug.Assert(Item == InternalItem);
                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a collection of indexes to <see cref="IndexCollectionList"/>:
        /// . For placeholder node and optional nodes, the collection is just one index.
        /// . For list of nodes, the collection contains as many indexes as nodes.
        /// . For block lists, the collection contains as many indexes as nodes. The first index of each block is a new block index, and others existing block indexes.
        /// </summary>
        /// <param name="collection">The collection to add.</param>
        public virtual void AddIndexCollection(IReadOnlyIndexCollection collection)
        {
            Debug.Assert(IsCollectionSeparate(collection, IndexCollectionList));

            InternalIndexCollectionList.Add(collection);

            Debug.Assert(collection.IsEmpty || !IsCollectionSeparate(collection, IndexCollectionList));
        }
 bool ICollection <IReadOnlyIndexCollection> .Contains(IReadOnlyIndexCollection value)
 {
     return(Contains((IFrameIndexCollection)value));
 }
 void ICollection <IReadOnlyIndexCollection> .Add(IReadOnlyIndexCollection item)
 {
     Add((IFrameIndexCollection)item);
 }
 void IList <IReadOnlyIndexCollection> .Insert(int index, IReadOnlyIndexCollection item)
 {
     Insert(index, (IFrameIndexCollection)item);
 }
 int IList <IReadOnlyIndexCollection> .IndexOf(IReadOnlyIndexCollection value)
 {
     return(IndexOf((IFrameIndexCollection)value));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Creates a IxxxOptionalInner{IxxxBrowsingOptionalNodeIndex} object.
 /// </summary>
 private protected override IReadOnlyOptionalInner <IReadOnlyBrowsingOptionalNodeIndex> CreateOptionalInner(IReadOnlyNodeState owner, IReadOnlyIndexCollection <IReadOnlyBrowsingOptionalNodeIndex> nodeIndexCollection)
 {
     ControllerTools.AssertNoOverride(this, Type.FromTypeof <FocusController>());
     return(new FocusOptionalInner <IFocusBrowsingOptionalNodeIndex>((IFocusNodeState)owner, nodeIndexCollection.PropertyName));
 }
        private protected virtual IReadOnlyInner BuildInner(IReadOnlyNodeState parentState, IReadOnlyIndexCollection nodeIndexCollection)
        {
            IReadOnlyInner Result = null;

            switch (nodeIndexCollection)
            {
            case IReadOnlyIndexCollection <IReadOnlyBrowsingPlaceholderNodeIndex> AsPlaceholderNodeIndexCollection:
                Result = (IReadOnlyPlaceholderInner)CreatePlaceholderInner(parentState, AsPlaceholderNodeIndexCollection);
                break;

            case IReadOnlyIndexCollection <IReadOnlyBrowsingOptionalNodeIndex> AsOptionalNodeIndexCollection:
                Result = (IReadOnlyOptionalInner)CreateOptionalInner(parentState, AsOptionalNodeIndexCollection);
                break;

            case IReadOnlyIndexCollection <IReadOnlyBrowsingListNodeIndex> AsListNodeIndexCollection:
                Stats.ListCount++;
                Result = (IReadOnlyListInner)CreateListInner(parentState, AsListNodeIndexCollection);
                break;

            case IReadOnlyIndexCollection <IReadOnlyBrowsingBlockNodeIndex> AsBlockNodeIndexCollection:
                Stats.BlockListCount++;
                IReadOnlyBlockListInner Inner = (IReadOnlyBlockListInner)CreateBlockListInner(parentState, AsBlockNodeIndexCollection);
                NotifyBlockListInnerCreated(Inner as IReadOnlyBlockListInner);
                Result = Inner;
                break;
            }

            Debug.Assert(Result != null);
            return(Result);
        }
 /// <summary>
 /// Creates a IxxxBlockListInner{IxxxBrowsingBlockNodeIndex} object.
 /// </summary>
 private protected override IReadOnlyBlockListInner <IReadOnlyBrowsingBlockNodeIndex> CreateBlockListInner(IReadOnlyNodeState owner, IReadOnlyIndexCollection <IReadOnlyBrowsingBlockNodeIndex> nodeIndexCollection)
 {
     ControllerTools.AssertNoOverride(this, Type.FromTypeof <LayoutController>());
     return(new LayoutBlockListInner <ILayoutBrowsingBlockNodeIndex>((ILayoutNodeState)owner, nodeIndexCollection.PropertyName));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Creates a IxxxListInner{IxxxBrowsingListNodeIndex} object.
 /// </summary>
 private protected override IReadOnlyListInner <IReadOnlyBrowsingListNodeIndex> CreateListInner(IReadOnlyNodeState owner, IReadOnlyIndexCollection <IReadOnlyBrowsingListNodeIndex> nodeIndexCollection)
 {
     ControllerTools.AssertNoOverride(this, typeof(LayoutController));
     return(new LayoutListInner <ILayoutBrowsingListNodeIndex, LayoutBrowsingListNodeIndex>((ILayoutNodeState)owner, nodeIndexCollection.PropertyName));
 }
Exemplo n.º 12
0
        private protected virtual void BrowseChildrenOfNode(IReadOnlyBrowseContext browseNodeContext, INode node)
        {
            IList <string> PropertyNames = NodeTreeHelper.EnumChildNodeProperties(node);

            foreach (string PropertyName in PropertyNames)
            {
                INode ChildNode;
                Type  ChildInterfaceType, ChildNodeType;
                IReadOnlyList <INode>          ChildNodeList;
                IReadOnlyList <INodeTreeBlock> ChildBlockList;
                bool IsHandled = false;

                if (NodeTreeHelperChild.IsChildNodeProperty(node, PropertyName, out ChildNodeType))
                {
                    NodeTreeHelperChild.GetChildNode(node, PropertyName, out ChildNode);
                    Debug.Assert(ChildNode != null);
                    IReadOnlyBrowsingPlaceholderNodeIndex ChildNodeIndex = CreateChildNodeIndex(browseNodeContext, node, PropertyName, ChildNode);

                    // Create a collection containing one index for this child node.
                    IReadOnlyIndexCollection IndexCollection = CreatePlaceholderIndexCollection(browseNodeContext, PropertyName, ChildNodeIndex);
                    browseNodeContext.AddIndexCollection(IndexCollection);

                    IsHandled = true;
                }
                else if (NodeTreeHelperOptional.IsOptionalChildNodeProperty(node, PropertyName, out ChildNodeType))
                {
                    IReadOnlyBrowsingOptionalNodeIndex OptionalNodeIndex = CreateOptionalNodeIndex(browseNodeContext, node, PropertyName);

                    // Create a collection containing one index for this optional node.
                    IReadOnlyIndexCollection IndexCollection = CreateOptionalIndexCollection(browseNodeContext, PropertyName, OptionalNodeIndex);
                    browseNodeContext.AddIndexCollection(IndexCollection);

                    IsHandled = true;
                }
                else if (NodeTreeHelperList.IsNodeListProperty(node, PropertyName, out ChildNodeType))
                {
                    NodeTreeHelperList.GetChildNodeList(node, PropertyName, out ChildNodeList);
                    Debug.Assert(ChildNodeList != null);

                    // Create a collection containing indexes for each children.
                    IReadOnlyIndexCollection IndexCollection = BrowseNodeList(browseNodeContext, node, PropertyName, ChildNodeList);
                    browseNodeContext.AddIndexCollection(IndexCollection);

                    IsHandled = true;
                }
                else if (NodeTreeHelperBlockList.IsBlockListProperty(node, PropertyName, out ChildInterfaceType, out ChildNodeType))
                {
                    NodeTreeHelperBlockList.GetChildBlockList(node, PropertyName, out ChildBlockList);
                    Debug.Assert(ChildBlockList != null);

                    // Create a collection containing indexes for each child blocks and their children.
                    IReadOnlyIndexCollection IndexCollection = BrowseNodeBlockList(browseNodeContext, node, PropertyName, ChildBlockList);
                    browseNodeContext.AddIndexCollection(IndexCollection);

                    IsHandled = true;
                }
                else if (NodeTreeHelper.IsBooleanProperty(node, PropertyName))
                {
                    browseNodeContext.AddValueProperty(PropertyName, ValuePropertyType.Boolean);
                    IsHandled = true;
                }
                else if (NodeTreeHelper.IsEnumProperty(node, PropertyName))
                {
                    browseNodeContext.AddValueProperty(PropertyName, ValuePropertyType.Enum);
                    IsHandled = true;
                }
                else if (NodeTreeHelper.IsStringProperty(node, PropertyName))
                {
                    browseNodeContext.AddValueProperty(PropertyName, ValuePropertyType.String);
                    IsHandled = true;
                }
                else if (NodeTreeHelper.IsGuidProperty(node, PropertyName))
                {
                    browseNodeContext.AddValueProperty(PropertyName, ValuePropertyType.Guid);
                    IsHandled = true;
                }
                else if (NodeTreeHelper.IsDocumentProperty(node, PropertyName))
                {
                    IsHandled = true; // Ignore the doc node.
                }

                Debug.Assert(IsHandled);
            }
        }
 void ICollection <IReadOnlyIndexCollection> .Add(IReadOnlyIndexCollection item)
 {
     Add((IWriteableIndexCollection)item);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Creates a IxxxBlockListInner{IxxxBrowsingBlockNodeIndex} object.
 /// </summary>
 private protected override IReadOnlyBlockListInner <IReadOnlyBrowsingBlockNodeIndex> CreateBlockListInner(IReadOnlyNodeState owner, IReadOnlyIndexCollection <IReadOnlyBrowsingBlockNodeIndex> nodeIndexCollection)
 {
     ControllerTools.AssertNoOverride(this, typeof(FocusController));
     return(new FocusBlockListInner <IFocusBrowsingBlockNodeIndex, FocusBrowsingBlockNodeIndex>((IFocusNodeState)owner, nodeIndexCollection.PropertyName));
 }
Exemplo n.º 15
0
 /// <summary>
 /// Creates a IxxxOptionalInner{IxxxBrowsingOptionalNodeIndex} object.
 /// </summary>
 private protected override IReadOnlyOptionalInner <IReadOnlyBrowsingOptionalNodeIndex> CreateOptionalInner(IReadOnlyNodeState owner, IReadOnlyIndexCollection <IReadOnlyBrowsingOptionalNodeIndex> nodeIndexCollection)
 {
     ControllerTools.AssertNoOverride(this, typeof(FrameController));
     return(new FrameOptionalInner <IFrameBrowsingOptionalNodeIndex, FrameBrowsingOptionalNodeIndex>((IFrameNodeState)owner, nodeIndexCollection.PropertyName));
 }
 void ICollection <IReadOnlyIndexCollection> .Add(IReadOnlyIndexCollection item)
 {
     Add((ILayoutIndexCollection)item);
 }
 /// <summary>
 /// Creates a IxxxPlaceholderInner{IxxxBrowsingPlaceholderNodeIndex} object.
 /// </summary>
 private protected virtual IReadOnlyPlaceholderInner <IReadOnlyBrowsingPlaceholderNodeIndex> CreatePlaceholderInner(IReadOnlyNodeState owner, IReadOnlyIndexCollection <IReadOnlyBrowsingPlaceholderNodeIndex> nodeIndexCollection)
 {
     ControllerTools.AssertNoOverride(this, Type.FromTypeof <ReadOnlyController>());
     return(new ReadOnlyPlaceholderInner <IReadOnlyBrowsingPlaceholderNodeIndex>(owner, nodeIndexCollection.PropertyName));
 }
 bool ICollection <IReadOnlyIndexCollection> .Remove(IReadOnlyIndexCollection item)
 {
     return(Remove((IFrameIndexCollection)item));
 }
Exemplo n.º 19
0
 /// <summary>
 /// Creates a IxxxListInner{IxxxBrowsingListNodeIndex} object.
 /// </summary>
 private protected override IReadOnlyListInner <IReadOnlyBrowsingListNodeIndex> CreateListInner(IReadOnlyNodeState owner, IReadOnlyIndexCollection <IReadOnlyBrowsingListNodeIndex> nodeIndexCollection)
 {
     ControllerTools.AssertNoOverride(this, Type.FromTypeof <FrameController>());
     return(new FrameListInner <IFrameBrowsingListNodeIndex>((IFrameNodeState)owner, nodeIndexCollection.PropertyName));
 }
 int IReadOnlyIndexCollectionReadOnlyList.IndexOf(IReadOnlyIndexCollection value)
 {
     return(IndexOf((IWriteableIndexCollection)value));
 }
Exemplo n.º 21
0
 bool IReadOnlyIndexCollectionReadOnlyList.Contains(IReadOnlyIndexCollection value)
 {
     return(Contains((IFocusIndexCollection)value));
 }
Exemplo n.º 22
0
 /// <summary>
 /// Creates a IxxxPlaceholderInner{IxxxBrowsingPlaceholderNodeIndex} object.
 /// </summary>
 private protected override IReadOnlyPlaceholderInner <IReadOnlyBrowsingPlaceholderNodeIndex> CreatePlaceholderInner(IReadOnlyNodeState owner, IReadOnlyIndexCollection <IReadOnlyBrowsingPlaceholderNodeIndex> nodeIndexCollection)
 {
     ControllerTools.AssertNoOverride(this, Type.FromTypeof <WriteableController>());
     return(new WriteablePlaceholderInner <IWriteableBrowsingPlaceholderNodeIndex>((IWriteableNodeState)owner, nodeIndexCollection.PropertyName));
 }
Exemplo n.º 23
0
 int IReadOnlyIndexCollectionReadOnlyList.IndexOf(IReadOnlyIndexCollection value)
 {
     return(IndexOf((IFocusIndexCollection)value));
 }
 bool IReadOnlyIndexCollectionReadOnlyList.Contains(IReadOnlyIndexCollection value)
 {
     return(Contains((IWriteableIndexCollection)value));
 }