AnsweredAssumed Answered

Get all assemblies down to the top level

Question asked by Steve Anderson on Dec 18, 2019

Hello:

 

Here is my code.  It only looks down one level.  My goal is to get the topmost assembly (parent) for each assembly referenced.

 

Public Sub GetParentReferences(ByVal _afile As IEdmFile7)
Dim aPos As IEdmPos5 = Nothing

aPos = _afile.GetFirstFolderPosition
If aPos Is Nothing Then Throw New Exception("Failed to get Position")

Dim parentFolder As IEdmFolder5 = _afile.GetNextFolder(aPos)
If parentFolder Is Nothing Then Throw New Exception("Failed to get Folder")

'Get an interface to the reference tree
Dim ref As IEdmReference7
ref = _afile.GetReferenceTree(parentFolder.ID)

'Enumerate parent references
Dim msg As String
msg = "Top Level: " & _afile.Name + vbLf
Dim pos As IEdmPos5
pos = ref.GetFirstParentPosition2(0, False, EdmRefFlags.EdmRef_File + EdmRefFlags.EdmRef_Item + EdmRefFlags.EdmRef_Dynamic + EdmRefFlags.EdmRef_Static)

Dim parent As IEdmReference7
While Not pos.IsNull
parent = ref.GetNextParent(pos)
If System.IO.Path.GetExtension(_afile.Name).ToUpper = ".SLDASM" Then
If (Asc(Microsoft.VisualBasic.Left(System.IO.Path.GetFileNameWithoutExtension(_afile.Name).ToUpper, 1)) >= 65) And
(Asc(Microsoft.VisualBasic.Left(System.IO.Path.GetFileNameWithoutExtension(_afile.Name).ToUpper, 1)) <= 69) Then
If System.IO.Path.GetExtension(parent.File.Name).ToUpper = ".SLDASM" Then
If (Asc(Microsoft.VisualBasic.Left(System.IO.Path.GetFileNameWithoutExtension(parent.File.Name).ToUpper, 1)) >= 65) And
(Asc(Microsoft.VisualBasic.Left(System.IO.Path.GetFileNameWithoutExtension(parent.File.Name).ToUpper, 1)) <= 69) Then
msg = msg + parent.File.Name + vbLf
GetParentReferences(parent.File)

End If

End If

End If

End If

End While

msg = msg + "Nothing" + vbLf

Debug.WriteLine(msg)

End Sub

 

Thanks!

Outcomes