/// <summary>
        /// Used to receive notifications when a node is browsed.
        /// </summary>
        public void OnPopulateBrowser(
            ISystemContext context,
            NodeState node,
            NodeBrowser browser)
        {
            ParsedNodeId  nodeId = ParsedNodeId.Parse(node.NodeId);
            DirectoryInfo info   = new DirectoryInfo(nodeId.RootId);

            if (!info.Exists)
            {
                return;
            }

            if (browser.IsRequired(ReferenceTypeIds.Organizes, false))
            {
                foreach (DirectoryInfo child in info.GetDirectories())
                {
                    ParsedNodeId childId = new ParsedNodeId();
                    childId.RootType       = 0;
                    childId.RootId         = child.FullName;
                    childId.NamespaceIndex = NamespaceIndex;

                    browser.Add(new NodeStateReference(ReferenceTypeIds.Organizes, false, childId.Construct()));
                }
            }

            if (browser.IsRequired(ReferenceTypeIds.Organizes, true))
            {
                ParsedNodeId parentId = new ParsedNodeId();
                parentId.RootType       = 0;
                parentId.RootId         = info.Parent.FullName;
                parentId.NamespaceIndex = NamespaceIndex;

                browser.Add(new NodeStateReference(ReferenceTypeIds.Organizes, true, parentId.Construct()));
            }
        }
Beispiel #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))
            {
                if (!(context.SystemHandle is UnderlyingSystem system))
                {
                    return;
                }

                // add reference for parent segment.
                var segment = system.FindParentForSegment(SegmentPath);

                if (segment != null)
                {
                    browser.Add(ReferenceTypeIds.Organizes, true, ModelUtils.ConstructIdForSegment(segment.Id, NodeId.NamespaceIndex));
                }
            }
        }
Beispiel #3
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))
            {
                if (!(context.SystemHandle is UnderlyingSystem system))
                {
                    return;
                }

                // add reference for each segment.
                var segments = system.FindSegmentsForBlock(_blockId);

                for (var ii = 0; ii < segments.Count; ii++)
                {
                    browser.Add(ReferenceTypeIds.Organizes, true, ModelUtils.ConstructIdForSegment(segments[ii].Id, NodeId.NamespaceIndex));
                }
            }
        }