示例#1
0
        /// <summary>
        /// Populates the browser with references that meet the criteria.
        /// </summary>
        /// <param name="context">The context for the system being accessed.</param>
        /// <param name="browser">The browser to populate.</param>
        protected override void PopulateBrowser(ISystemContext context, NodeBrowser browser)
        {
            base.PopulateBrowser(context, browser);

            // check if the parent segments need to be returned.
            if (browser.IsRequired(ReferenceTypeIds.Organizes, true))
            {
                UnderlyingSystem system = context.SystemHandle as UnderlyingSystem;

                if (system == null)
                {
                    return;
                }

                // add reference for each segment.
                IList <UnderlyingSystemSegment> segments = system.FindSegmentsForBlock(m_blockId);

                for (int ii = 0; ii < segments.Count; ii++)
                {
                    browser.Add(ReferenceTypeIds.Organizes, true, ModelUtils.ConstructIdForSegment(segments[ii].Id, this.NodeId.NamespaceIndex));
                }
            }
        }
示例#2
0
        /// <summary>
        /// Populates the browser with references that meet the criteria.
        /// </summary>
        /// <param name="context">The context for the system being accessed.</param>
        /// <param name="browser">The browser to populate.</param>
        protected override void PopulateBrowser(ISystemContext context, NodeBrowser browser)
        {
            base.PopulateBrowser(context, browser);

            // check if the parent segments need to be returned.
            if (browser.IsRequired(ReferenceTypeIds.Organizes, true))
            {
                UnderlyingSystem system = context.SystemHandle as UnderlyingSystem;

                if (system == null)
                {
                    return;
                }

                // add reference for parent segment.
                UnderlyingSystemSegment segment = system.FindParentForSegment(m_segmentPath);

                if (segment != null)
                {
                    browser.Add(ReferenceTypeIds.Organizes, true, ModelUtils.ConstructIdForSegment(segment.Id, this.NodeId.NamespaceIndex));
                }
            }
        }
示例#3
0
        /// <summary>
        /// Returns the next child.
        /// </summary>
        private IReference NextChild()
        {
            UnderlyingSystem system = (UnderlyingSystem)this.SystemContext.SystemHandle;

            NodeId targetId = null;

            // check if a specific browse name is requested.
            if (!QualifiedName.IsNull(base.BrowseName))
            {
                // check if match found previously.
                if (m_position == Int32.MaxValue)
                {
                    return(null);
                }

                // browse name must be qualified by the correct namespace.
                if (m_source.BrowseName.NamespaceIndex != base.BrowseName.NamespaceIndex)
                {
                    return(null);
                }

                // look for matching segment.
                if (m_stage == Stage.Segments && m_segments != null)
                {
                    for (int ii = 0; ii < m_segments.Count; ii++)
                    {
                        if (base.BrowseName.Name == m_segments[ii].Name)
                        {
                            targetId = ModelUtils.ConstructIdForSegment(m_segments[ii].Id, m_source.NodeId.NamespaceIndex);
                            break;
                        }
                    }
                }

                // look for matching block.
                if (m_stage == Stage.Blocks && m_blocks != null)
                {
                    for (int ii = 0; ii < m_blocks.Count; ii++)
                    {
                        UnderlyingSystemBlock block = system.FindBlock(m_blocks[ii]);

                        if (block != null && base.BrowseName.Name == block.Name)
                        {
                            targetId = ModelUtils.ConstructIdForBlock(m_blocks[ii], m_source.NodeId.NamespaceIndex);
                            break;
                        }
                    }
                }

                m_position = Int32.MaxValue;
            }

            // return the child at the next position.
            else
            {
                // look for next segment.
                if (m_stage == Stage.Segments && m_segments != null)
                {
                    if (m_position >= m_segments.Count)
                    {
                        return(null);
                    }

                    targetId = ModelUtils.ConstructIdForSegment(m_segments[m_position++].Id, m_source.NodeId.NamespaceIndex);
                }

                // look for next block.
                else if (m_stage == Stage.Blocks && m_blocks != null)
                {
                    if (m_position >= m_blocks.Count)
                    {
                        return(null);
                    }

                    targetId = ModelUtils.ConstructIdForBlock(m_blocks[m_position++], m_source.NodeId.NamespaceIndex);
                }
            }

            // create reference.
            if (targetId != null)
            {
                return(new NodeStateReference(ReferenceTypeIds.Organizes, false, targetId));
            }

            return(null);
        }