Inheritance: HierarchyNode, IReferenceContainer
Esempio n. 1
0
        /// <summary>
        /// Links a reference node to the project and hierarchy.
        /// </summary>
        public virtual void AddReference()
        {
            ReferenceContainerNode referencesFolder = this.ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode;

            Debug.Assert(referencesFolder != null, "Could not find the References node");

            CannotAddReferenceErrorMessage referenceErrorMessageHandler = null;

            if (!this.CanAddReference(out referenceErrorMessageHandler))
            {
                if (referenceErrorMessageHandler != null)
                {
                    referenceErrorMessageHandler.DynamicInvoke(new object[] { });
                }
                return;
            }

            // Link the node to the project file.
            this.BindReferenceData();

            // At this point force the item to be refreshed
            this.ItemNode.RefreshProperties();

            referencesFolder.AddChild(this);

            return;
        }
Esempio n. 2
0
        /// <summary>
        /// Checks if an assembly is already added. The method parses all references and compares the full
        /// assembly names, or the location of the assemblies to decide whether two assemblies are the same.
        /// </summary>
        /// <returns>true if the assembly has already been added.</returns>
        protected internal override bool IsAlreadyAdded(out ReferenceNode existingReference)
        {
            ReferenceContainerNode referencesFolder = this.ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode;

            Debug.Assert(referencesFolder != null, "Could not find the References node");
            bool shouldCheckPath = !string.IsNullOrEmpty(this.Url);

            for (HierarchyNode n = referencesFolder.FirstChild; n != null; n = n.NextSibling)
            {
                AssemblyReferenceNode assemblyReferenceNode = n as AssemblyReferenceNode;
                if (null != assemblyReferenceNode)
                {
                    // We will check if the full assembly names are the same or if the Url of the assemblies is the same.
                    if (String.Compare(assemblyReferenceNode.AssemblyName.FullName, this.assemblyName.FullName, StringComparison.OrdinalIgnoreCase) == 0 ||
                        (shouldCheckPath && NativeMethods.IsSamePath(assemblyReferenceNode.Url, this.Url)))
                    {
                        existingReference = assemblyReferenceNode;
                        return(true);
                    }
                }
            }

            existingReference = null;
            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// Links a reference node to the project and hierarchy.
        /// </summary>
        public virtual /*void*/ ReferenceNode AddReference()          //
        {
            XSharpProjectPackage.Instance.UIThread.MustBeCalledFromUIThread();

            ReferenceNode existingNode = null;  /// returns existing node or null if this node has been newly added

            ReferenceContainerNode referencesFolder = this.ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode;

            Debug.Assert(referencesFolder != null, "Could not find the References node");

            CannotAddReferenceErrorMessage referenceErrorMessageHandler = null;

            if (!this.CanAddReference(out referenceErrorMessageHandler, out existingNode))
            {
                if (referenceErrorMessageHandler != null)
                {
                    referenceErrorMessageHandler.DynamicInvoke(new object[] { });
                }
                return(existingNode);
            }
            // Link the node to the project file.
            this.BindReferenceData();

            // At this point force the item to be refreshed
            this.ItemNode.RefreshProperties();

            referencesFolder.AddChild(this);

            return(existingNode);
        }
Esempio n. 4
0
        /// <summary>
        /// Checks if a reference is already added. The method parses all references and compares the the FinalItemSpec and the Guid.
        /// </summary>
        /// <returns>true if the assembly has already been added.</returns>
        protected internal override bool IsAlreadyAdded(out ReferenceNode existingReference)
        {
            ReferenceContainerNode referencesFolder = this.ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode;

            Debug.Assert(referencesFolder != null, "Could not find the References node");

            for (HierarchyNode n = referencesFolder.FirstChild; n != null; n = n.NextSibling)
            {
                ComReferenceNode referenceNode = n as ComReferenceNode;

                if (referenceNode != null)
                {
                    // We check if the name and guids are the same
                    if (referenceNode.TypeGuid == this.TypeGuid &&
                        referenceNode.WrapperTool == this.WrapperTool &&
                        referenceNode.MajorVersionNumber == this.MajorVersionNumber &&
                        referenceNode.MinorVersionNumber == this.MinorVersionNumber)
                    {
                        existingReference = referenceNode;
                        return(true);
                    }
                }
            }

            existingReference = null;
            return(false);
        }
        /// <summary>
        /// Checks if a reference is already added. The method parses all references and compares the Url.
        /// </summary>
        /// <returns>true if the assembly has already been added.</returns>
        protected virtual bool IsAlreadyAdded()
        {
            ReferenceContainerNode referencesFolder = this.ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode;

            Debug.Assert(referencesFolder != null, "Could not find the References node");

            for (HierarchyNode n = referencesFolder.FirstChild; n != null; n = n.NextSibling)
            {
                ReferenceNode refererenceNode = n as ReferenceNode;
                if (null != refererenceNode)
                {
                    // We check if the Url of the assemblies is the same.
                    if (NativeMethods.IsSamePath(refererenceNode.Url, this.Url))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 6
0
        /// <summary>
        /// Checks if a reference is already added. The method parses all references and compares the the FinalItemSpec and the Guid.
        /// </summary>
        /// <returns>true if the assembly has already been added.</returns>
        protected override bool IsAlreadyAdded()
        {
            ReferenceContainerNode referencesFolder = this.ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode;

            Debug.Assert(referencesFolder != null, "Could not find the References node");

            for (HierarchyNode n = referencesFolder.FirstChild; n != null; n = n.NextSibling)
            {
                ComReferenceNode refererenceNode = n as ComReferenceNode;

                if (refererenceNode != null)
                {
                    // We check if the name and guids are the same
                    if (refererenceNode.TypeGuid == this.TypeGuid && String.Compare(refererenceNode.Caption, this.Caption, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        /// <summary>
        /// Checks if an assembly is already added. The method parses all references and compares the full assemblynames, or the location of the assemblies to decide whether two assemblies are the same.
        /// </summary>
        /// <returns>true if the assembly has already been added.</returns>
        protected internal override bool IsAlreadyAdded(out ReferenceNode existingReference)
        {
            ReferenceContainerNode referencesFolder = this.ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode;

            Debug.Assert(referencesFolder != null, "Could not find the References node");

            for (HierarchyNode n = referencesFolder.FirstChild; n != null; n = n.NextSibling)
            {
                ApplicationReferenceNode referenceNode = n as ApplicationReferenceNode;
                if (null != referenceNode)
                {
                    // If the reference url (path) is the same, they are equal.
                    if (String.Compare(referenceNode.Url, this.Url, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        existingReference = referenceNode;
                        return(true);
                    }
                }
            }

            existingReference = null;
            return(false);
        }
Esempio n. 8
0
        /// <summary>
        /// Checks if a reference is already added. The method parses all references and compares the FinalItemSpec and the GUID.
        /// </summary>
        /// <returns>true if the assembly has already been added.</returns>
        public override bool IsAlreadyAdded(out ReferenceNode existingEquivalentNode)
        {
            ReferenceContainerNode referencesFolder = this.ProjectManager.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode;

            Debug.Assert(referencesFolder != null, "Could not find the References node");

            for (HierarchyNode n = referencesFolder.FirstChild; n != null; n = n.NextSibling)
            {
                ComReferenceNode referenceNode = n as ComReferenceNode;

                if (referenceNode != null)
                {
                    // We check if the name and GUIDs are the same
                    if (referenceNode.TypeGuid == this.TypeGuid && String.Equals(referenceNode.Caption, this.Caption, StringComparison.OrdinalIgnoreCase))
                    {
                        existingEquivalentNode = referenceNode;
                        return(true);
                    }
                }
            }

            existingEquivalentNode = null;
            return(false);
        }
 public NemerleOAReferenceFolderItem(OAProject project, ReferenceContainerNode node)
     : base(project, node)
 {
 }