src/Misc/EFTools/DesignXmlCore/VisualStudio/VSHelpers.cs
/// <summary>
///     Determines if the file can be checked out on edit and checks out if necessary
/// </summary>
/// <param name="serviceProvider">IServiceProvider</param>
/// <param name="moniker">file to checkout</param>
/// <returns>true/false depending on </returns>
Determines if the file can be checked out on edit and checks out if necessary
Determines if the file can be checked out on edit and checks out if necessary
internal static bool CheckOutFilesIfSaveable(IServiceProvider serviceProvider, string[] documents)
        {
            if (documents.Length > 0)
            {
                var queryEditQuerySave = serviceProvider.GetService(typeof(SVsQueryEditQuerySave)) as IVsQueryEditQuerySave2;
                if (queryEditQuerySave != null)
                {
                    uint result;
                    var hr = queryEditQuerySave.QuerySaveFiles(
                        0, 
                        documents.Length, 
                        documents, 
                        null, 
                        null, 
                        out result 
                        );
                    if (NativeMethods.Succeeded(hr)
                        && (result == (uint)tagVSQueryEditResult.QER_EditOK))
                    {
                        return true;
                    }
                }
                else
                {
                    Debug.Fail("Not able to get the IVsQueryEditQuerySave2 service");
                }
            }
            else
            {
                return true;
            }
            return false;
        }
internal static bool CheckOutFilesIfSaveable ( IServiceProvider serviceProvider , string [ ] documents ) { if ( documents . Length > 0 ) { var queryEditQuerySave = serviceProvider . GetService ( typeof ( SVsQueryEditQuerySave ) ) as IVsQueryEditQuerySave2 ; if ( queryEditQuerySave != null ) { uint result ; var hr = queryEditQuerySave . QuerySaveFiles ( 0 , documents . Length , documents , null , null , out result ) ; if ( NativeMethods . Succeeded ( hr ) && ( result == ( uint ) tagVSQueryEditResult . QER_EditOK ) ) { return true ; } } else { Debug . Fail ( " " ) ; } } else { return true ; } return false ; }
Determines if the file can be checked out on edit and checks out if necessary
Determines if the file can be checked out on edit and checks out if necessary
// query the VS SCC provider and ask if we can edit the file // This may bring up a UI to ask the user to checkout a file depending on the user's settings. // NOTE that we should not allow the QEF_ImplicitEdit input flag because this is the wrong user experience and the user // can override this in Tools->Options, which can lead to false assumptions here and more bugs. // Flags tagVSQueryEditFlags.QEF_AllowInMemoryEdits=0 // Number of elements in the array // Files to edit // Input flags // Input array of VSQEQS_FILE_ATTRIBUTE_DATA // result of the checkout
true/false depending on
true / false depending on
serviceProvider
IServiceProvider
None
documents
string[]
moniker
file to checkout
file to checkout