/// <summary> /// Checks if a reference is already added. The method parses all references and compares the Url. /// </summary> /// <param name="existingEquivalentNode">The existing reference, if one is found.</param> /// <returns>true if the assembly has already been added.</returns> protected internal virtual bool IsAlreadyAdded(out ReferenceNode existingEquivalentNode) { var referencesFolder = ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode; Debug.Assert(referencesFolder != null, "Could not find the References node"); for (var n = referencesFolder.FirstChild; n != null; n = n.NextSibling) { var referenceNode = n as ReferenceNode; if (null != referenceNode) { // We check if the Url of the assemblies is the same. if (NativeMethods.IsSamePath(referenceNode.Url, Url)) { existingEquivalentNode = referenceNode; return true; } } } existingEquivalentNode = null; return false; }
/// <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) { var referencesFolder = ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode; Debug.Assert(referencesFolder != null, "Could not find the References node"); for (var n = referencesFolder.FirstChild; n != null; n = n.NextSibling) { var referenceNode = n as ComReferenceNode; if (referenceNode != null) { // We check if the name and guids are the same if (referenceNode.TypeGuid == TypeGuid && string.Compare(referenceNode.Caption, Caption, StringComparison.OrdinalIgnoreCase) == 0) { existingReference = referenceNode; return true; } } } existingReference = null; 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) { var referencesFolder = ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode; Debug.Assert(referencesFolder != null, "Could not find the References node"); var shouldCheckPath = !string.IsNullOrEmpty(Url); for (var n = referencesFolder.FirstChild; n != null; n = n.NextSibling) { var assemblyReferenceNode = n as AssemblyReferenceNode; if (null != assemblyReferenceNode) { // We will check if the full assemblynames are the same or if the Url of the assemblies is the same. if ( string.Compare(assemblyReferenceNode.AssemblyName.FullName, assemblyName.FullName, StringComparison.OrdinalIgnoreCase) == 0 || (shouldCheckPath && NativeMethods.IsSamePath(assemblyReferenceNode.Url, Url))) { existingReference = assemblyReferenceNode; return true; } } } existingReference = null; return false; }