public CompendiumTransclusionRelationship(IRelationship relationship, CompendiumViewRelationship viewRelationship, INode toNode, INode fromNode, INode transclusionNode, INode mapNode)
            : this()
        {
            _toNode = toNode;
            IDescriptor toDescriptor = new CompendiumRelationshipDescriptor(toNode, this, IoCContainer.GetInjectionInstance().GetInstance<CompendiumToDescriptor>());
            _descriptors.Add(toDescriptor);
            _toNode.AddDescriptor(toDescriptor);

            _fromNode = fromNode;
            IDescriptor fromDescriptor = new CompendiumRelationshipDescriptor(fromNode, this, IoCContainer.GetInjectionInstance().GetInstance<CompendiumFromDescriptor>());
            _descriptors.Add(fromDescriptor);
            _fromNode.AddDescriptor(fromDescriptor);

            _transclusionNode = transclusionNode;
            IDescriptor transclusionNodeDescriptor = new CompendiumRelationshipDescriptor(transclusionNode, this, IoCContainer.GetInjectionInstance().GetInstance<CompendiumTransclusionNodeDescriptor>());
            _descriptors.Add(transclusionNodeDescriptor);
            _transclusionNode.AddDescriptor(transclusionNodeDescriptor);

            _mapNode = mapNode;
            IDescriptor mapDescriptor = new CompendiumRelationshipDescriptor(mapNode, this, IoCContainer.GetInjectionInstance().GetInstance<CompendiumTransclusionMapDescriptor>());
            _descriptors.Add(mapDescriptor);
            _mapNode.AddDescriptor(mapDescriptor);

            this.Id = relationship.Id;
            this.Created = relationship.Created;
            this.CreatedBy = relationship.CreatedBy;
            this.LastModified = relationship.LastModified;
            this.Name = relationship.Name;
            this.XPosition = viewRelationship.XPosition;
            this.YPosition = viewRelationship.YPosition;
        }
Пример #2
0
        public CompendiumTransclusionRelationship(IRelationship relationship, CompendiumViewRelationship viewRelationship, INode toNode, INode fromNode, INode transclusionNode, INode mapNode)
            : this()
        {
            _toNode = toNode;
            IDescriptor toDescriptor = new CompendiumRelationshipDescriptor(toNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumToDescriptor>());

            _descriptors.Add(toDescriptor);
            _toNode.AddDescriptor(toDescriptor);

            _fromNode = fromNode;
            IDescriptor fromDescriptor = new CompendiumRelationshipDescriptor(fromNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumFromDescriptor>());

            _descriptors.Add(fromDescriptor);
            _fromNode.AddDescriptor(fromDescriptor);

            _transclusionNode = transclusionNode;
            IDescriptor transclusionNodeDescriptor = new CompendiumRelationshipDescriptor(transclusionNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumTransclusionNodeDescriptor>());

            _descriptors.Add(transclusionNodeDescriptor);
            _transclusionNode.AddDescriptor(transclusionNodeDescriptor);

            _mapNode = mapNode;
            IDescriptor mapDescriptor = new CompendiumRelationshipDescriptor(mapNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumTransclusionMapDescriptor>());

            _descriptors.Add(mapDescriptor);
            _mapNode.AddDescriptor(mapDescriptor);

            this.Id           = relationship.Id;
            this.Created      = relationship.Created;
            this.CreatedBy    = relationship.CreatedBy;
            this.LastModified = relationship.LastModified;
            this.Name         = relationship.Name;
            this.XPosition    = viewRelationship.XPosition;
            this.YPosition    = viewRelationship.YPosition;
        }
Пример #3
0
        public bool Load(XmlReader xml, string documentLibraryUrl)
        {
            _xml = xml;

            List<CompendiumViewRelationship> viewRelationships = new List<CompendiumViewRelationship>();
            bool isDomainNodeRootMapNode = false;

            if (_xml != null && _xml.NodeType == XmlNodeType.Element && _xml.Name == COMPENDIUM_DOCUMENT_TAG)
            {
                _xml.MoveToAttribute("rootview");
                string domainNodeId = _xml.Value;
                
                while (_xml.Read())
                {
                    if (_xml.NodeType == XmlNodeType.Element)
                    {
                        switch (_xml.Name)
                        {
                            case VIEW_RELATIONSHIP_TAG:
                                CompendiumViewRelationship viewRelationship = new CompendiumViewRelationship();
                                viewRelationship.ConsumeViewXml(_xml, domainNodeId);
                                viewRelationships.Add(viewRelationship);
                                break;

                            case NODE_DETAILS_TAG:
                                XmlCompendiumNode node = new XmlCompendiumNode(_xml, domainNodeId, documentLibraryUrl);
                                _nodes.Add(node.Id, node);
                                break;

                            case LINK_RELATIONSHIP_TAG:
                                CompendiumLinkRelationship nodeRelationship = new CompendiumLinkRelationship();
                                if (nodeRelationship.ConsumeLinkXml(_nodes, _xml, domainNodeId))
                                {
                                    isDomainNodeRootMapNode = true;
                                }
                                break;

                            default:
                                break;
                        }
                    }
                    else if (_xml.NodeType == XmlNodeType.EndElement)
                    {
                        if (_xml.Name == COMPENDIUM_DOCUMENT_TAG)
                        {
                            break;
                        }
                    }
                }
                if (isDomainNodeRootMapNode)
                {
                    _nodes[domainNodeId].NodeType = IoCContainer.GetInjectionInstance().GetInstance<IMapManager>().NodeTypes["CompendiumMapNode"];
                }
            }

            foreach (CompendiumViewRelationship viewRelationship in viewRelationships)
            {
                viewRelationship.BuildRelationships(_nodes);

                if (!_rootViewRelationships.Contains(viewRelationship) && viewRelationship.IsRootView)
                {
                    _rootViewRelationships.Add(viewRelationship);
                }
            }

            List<string> transcludedNodes = new List<string>();
            List<string> nonTranscludedNodes = new List<string>();

            foreach (CompendiumViewRelationship viewRelationship in viewRelationships)
            {
                if (nonTranscludedNodes.Contains(viewRelationship.FromNode.Id))
                {
                    /// If this node is in the non-transcluded nodes list then it means it IS a transclusion and needs to be moved out of the transcluded nodes list.
                    transcludedNodes.Add(viewRelationship.FromNode.Id);
                    nonTranscludedNodes.Remove(viewRelationship.FromNode.Id);

                    /// We need to notify all the link relationships for this node that they are part of a transclusion so their "Map" property means something.
                    foreach (IDescriptor descriptor in viewRelationship.FromNode.Descriptors)
                    {
                        if (descriptor.Relationship is CompendiumLinkRelationship)
                        {
                            CompendiumLinkRelationship linkRelationship = descriptor.Relationship as CompendiumLinkRelationship;

                            linkRelationship.ConvertToTransclusionRelationship(_nodes);
                        }
                    }
                }
                else if (!transcludedNodes.Contains(viewRelationship.FromNode.Id))
                {
                    /// If this ID isn't in the non-transcluded nodes list and it's not in the transcluded nodes list, then it means we haven't added yet.
                    nonTranscludedNodes.Add(viewRelationship.FromNode.Id);
                }
            }

            return isDomainNodeRootMapNode;
        }