in vsintegration/src/FSharp.ProjectSystem.PropertyPages/PropertyPages/PropPageUserControlBase.vb [1235:1397]
Public Overridable Sub SetObjects(ByVal objects() As Object)
Debug.Assert(m_Site IsNot Nothing OrElse (objects Is Nothing OrElse objects.Length = 0), "SetObjects() called (with non-null objects), but we are not sited!")
m_Objects = Nothing
m_fConfigurationSpecificPage = False
m_CachedRawPropertiesSuperset = Nothing
DisconnectPropertyNotify()
CheckMultipleProjectsSelected(objects)
If (objects Is Nothing) OrElse (objects.Length = 0) OrElse MultiProjectSelect() Then
EnableAllControls(False)
SetEnabledState()
CleanupCOMReferences()
Return
End If
If Not TypeOf objects Is Object() Then
Debug.Fail("Objects must be an array of Object, not an array of anything else!")
Throw New ArgumentException
End If
m_fInsideInit = True
Try
m_Objects = CType(objects.Clone(), Object())
SetEnabledState()
m_DTE = Nothing
m_DTEProject = Nothing
Dim Hier As IVsHierarchy = Nothing
Dim ItemId As UInteger
Dim ThisObj As Object = m_Objects(0)
If TypeOf ThisObj Is IVsCfgBrowseObject Then
m_fConfigurationSpecificPage = True
VSErrorHandler.ThrowOnFailure(CType(ThisObj, IVsCfgBrowseObject).GetProjectItem(Hier, ItemId))
ElseIf TypeOf ThisObj Is IVsBrowseObject Then
m_fConfigurationSpecificPage = False
VSErrorHandler.ThrowOnFailure(CType(ThisObj, IVsBrowseObject).GetProjectItem(Hier, ItemId))
Else
Debug.Fail("Object passed in to SetObjects() must be an IVsBrowseObject or IVsCfgBrowseObject")
Throw New NotSupportedException
End If
Debug.Assert(Hier IsNot Nothing, "Should have thrown")
m_ProjectHierarchy = Hier
Dim hr As Integer
Dim obj As Object = Nothing
hr = Hier.GetProperty(VSITEMID.ROOT, __VSHPROPID.VSHPROPID_ExtObject, obj)
If TypeOf obj Is EnvDTE.Project Then
m_DTEProject = CType(obj, EnvDTE.Project)
m_DTE = m_DTEProject.DTE
End If
hr = Hier.GetProperty(VSITEMID.ROOT, __VSHPROPID.VSHPROPID_BrowseObject, obj)
If TypeOf obj Is VSLangProj.ProjectProperties Then
m_ProjectPropertiesObject = CType(obj, VSLangProj.ProjectProperties)
ElseIf m_DTEProject IsNot Nothing Then
If TypeOf m_DTEProject.Object Is VSLangProj.ProjectProperties Then
m_ProjectPropertiesObject = CType(m_DTEProject.Object, VSLangProj.ProjectProperties)
Else
m_ProjectPropertiesObject = Nothing
End If
obj = Nothing
End If
obj = Nothing
Dim aem As Microsoft.VisualStudio.Editors.PropertyPages.AutomationExtenderManager = _
Microsoft.VisualStudio.Editors.PropertyPages.AutomationExtenderManager.GetAutomationExtenderManager(ServiceProvider)
Try
m_ExtendedObjects = aem.GetExtendedObjects(objects)
Debug.Assert(m_ExtendedObjects IsNot Nothing, "Extended objects unavailable")
m_ObjectsPropertyDescriptorsArray = New PropertyDescriptorCollection(objects.Length - 1) {}
For i As Integer = 0 To objects.Length - 1
Debug.Assert(objects(i) IsNot Nothing)
#If DEBUG Then
If Common.Switches.PDExtenders.TraceVerbose Then
TraceTypeDescriptorCollection("*** Non-extended properties collection for objects #" & i, TypeDescriptor.GetProperties(objects(i)))
End If
#End If
If TypeOf m_ExtendedObjects(i) Is ICustomTypeDescriptor Then
m_ObjectsPropertyDescriptorsArray(i) = CType(m_ExtendedObjects(i), ICustomTypeDescriptor).GetProperties(New Attribute() {})
Common.Switches.TracePDExtenders(TraceLevel.Info, "*** Properties collection #" & i & " contains extended properties.")
TraceTypeDescriptorCollection("*** Extended properties collection for objects #" & i, m_ObjectsPropertyDescriptorsArray(i))
Else
m_ObjectsPropertyDescriptorsArray(i) = System.ComponentModel.TypeDescriptor.GetProperties(objects(i))
Common.Switches.TracePDExtenders(TraceLevel.Info, "*** Properties collection #" & i & " does not contain extended properties.")
End If
Next i
Catch ex As Exception When Not Common.IsUnrecoverable(ex)
Debug.Fail("An exception was thrown trying to get extended objects for the properties" & vbCrLf & ex.ToString)
Throw
End Try
If objects.Length = 1 AndAlso CommonPropertiesObject Is objects(0) Then
Debug.Assert(Not m_fConfigurationSpecificPage)
m_CommonPropertyDescriptors = m_ObjectsPropertyDescriptorsArray(0)
Else
Try
Dim ExtendedCommonProperties() As Object = aem.GetExtendedObjects(New Object() {CommonPropertiesObject})
Debug.Assert(ExtendedCommonProperties IsNot Nothing, "Extended objects unavailable for common properties")
Debug.Assert(ExtendedCommonProperties.Length = 1)
#If DEBUG Then
If Common.Switches.PDExtenders.TraceVerbose Then
TraceTypeDescriptorCollection("*** Non-extended common properties collection", TypeDescriptor.GetProperties(CommonPropertiesObject))
End If
#End If
If TypeOf ExtendedCommonProperties(0) Is ICustomTypeDescriptor Then
m_CommonPropertyDescriptors = DirectCast(ExtendedCommonProperties(0), ICustomTypeDescriptor).GetProperties(New Attribute() {})
TraceTypeDescriptorCollection("*** Extended common properties collection", m_CommonPropertyDescriptors)
Else
m_CommonPropertyDescriptors = System.ComponentModel.TypeDescriptor.GetProperties(CommonPropertiesObject)
Common.Switches.TracePDExtenders(TraceLevel.Info, "*** Common properties collection does not contain extended properties.")
End If
Catch ex As Exception When Not Common.IsUnrecoverable(ex)
Debug.Fail("An exception was thrown trying to get extended objects for the common properties" & vbCrLf & ex.ToString)
Throw
End Try
End If
InitializeAllProperties()
InitPage()
ScaleWindowToCurrentFont()
ConnectBroadcastMessages()
ConnectDebuggerEvents()
ConnectPropertyNotify()
ConnectBuildEvents()
Finally
m_fInsideInit = False
End Try
For Each page As PropPageUserControlBase In m_ChildPages.Values
page.SetObjects(objects)
Next page
End Sub