Private Sub CheckOutFilesForApply()

in vsintegration/src/FSharp.ProjectSystem.PropertyPages/PropertyPages/PropPageUserControlBase.vb [1834:1921]


        Private Sub CheckOutFilesForApply()
            Dim Control As Control = Nothing 
            Dim FirstDirtyControl As Control = Nothing 
            Try
                
                
                
                
                
                
                If m_ServiceProvider IsNot Nothing AndAlso m_ProjectHierarchy IsNot Nothing Then
                    Dim SccManager As New DesignerFramework.SourceCodeControlManager(m_ServiceProvider, m_ProjectHierarchy)
                    For Each Data As PropertyControlData In ControlData
                        If Data.IsDirty Then
                            Dim ValueHasChanged As Boolean = False
                            Try
                                
                                
                                Dim OldValues() As Object = Data.AllInitialValuesExpanded
                                Dim NewValues() As Object = Data.GetControlValueMultipleValues()

                                If OldValues Is Nothing OrElse NewValues Is Nothing Then
                                    Debug.Fail("OldValues or NewValues is Nothing")
                                Else
                                    If OldValues.Length <> NewValues.Length Then
                                        Debug.Fail("OldValues.Length <> NewValues.Length")
                                    Else
                                        For i As Integer = 0 To OldValues.Length - 1
                                            If Not PropertyControlData.ObjectsAreEqual(OldValues(i), NewValues(i)) Then
                                                
                                                ValueHasChanged = True
                                            End If
                                        Next
                                    End If
                                End If

                            Catch ex As Exception When Not Common.Utils.IsUnrecoverable(ex)
                                Debug.Fail("Failure trying to compare old/new values in PropertyControlDataSetValueHelper.SetValue")
                                ValueHasChanged = True
                            End Try

                            
                            
                            
                            
                            If ValueHasChanged Then
                                If FirstDirtyControl Is Nothing Then
                                    FirstDirtyControl = Data.FormControl
                                End If
                                Control = Data.FormControl

                                Dim AffectedFiles() As String = Data.FilesToCheckOut() 
                                For Each File As String In AffectedFiles
                                    SccManager.ManageFile(File)
                                Next
                            End If
                        End If
                    Next

                    If SccManager.ManagedFiles.Count > 0 Then
                        Common.Switches.TracePDProperties(TraceLevel.Warning, "Calling QueryEdit on these files: " & String.Join(", ", SccManager.ManagedFiles.ToArray()))
                        SccManager.EnsureFilesEditable()

                        If m_ProjectReloadedDuringCheckout Then
                            
                            Trace.WriteLine("**** Dispose was forced while we were trying to check out files.  No property changes were made, exiting apply.")
                            Return
                        End If
                    End If
                Else
                    Debug.Fail("Service provider or hierarchy missing - can't QueryEdit files before property set")
                End If

            Catch ex As Exception When Not Common.IsUnrecoverable(ex)
                
                
                

                If Control Is Nothing Then
                    
                    
                    Control = FirstDirtyControl
                End If

                Throw New ValidationException(ValidationResult.Failed, ex.Message, Control, innerexception:=ex)
            End Try

        End Sub