src/T4Toolbox.VisualStudio/OutputFileManager.cs
/// <summary>
/// Uses the <see cref="SVsQueryEditQuerySave"/> service to checkout specified files with a minimum number of visual prompts.
/// </summary>
Uses the  service to checkout specified files with a minimum number of visual prompts.
Uses the service to checkout specified files with a minimum number of visual prompts .
private void CheckoutFiles(string[] filePaths)
        {
            var queryService = (IVsQueryEditQuerySave2)this.serviceProvider.GetService(typeof(SVsQueryEditQuerySave));
            if (queryService == null)
            {
                return;
            }
            uint editInfo;
            uint editResult;
            ErrorHandler.ThrowOnFailure(queryService.QueryEditFiles((uint)tagVSQueryEditFlags.QEF_DisallowInMemoryEdits, filePaths.Length, filePaths, null, null, out editResult, out editInfo));
            if (editResult == (uint)tagVSQueryEditResult.QER_EditOK)
            {
                return;
            }
            if (editResult == (uint)tagVSQueryEditResult.QER_NoEdit_UserCanceled && 
                (editInfo & (uint)tagVSQueryEditResultFlags.QER_CheckoutCanceledOrFailed) == (uint)tagVSQueryEditResultFlags.QER_CheckoutCanceledOrFailed)
            {
                throw CheckoutAbortedException();
            }
            ErrorHandler.ThrowOnFailure(queryService.BeginQuerySaveBatch()); 
            try
            {
                uint saveResult;
                ErrorHandler.ThrowOnFailure(queryService.QuerySaveFiles(0, filePaths.Length, filePaths, null, null, out saveResult));
                if (saveResult != (uint)tagVSQuerySaveResult.QSR_SaveOK)
                {
                    throw CheckoutAbortedException();
                }
            }
            finally
            {
                ErrorHandler.ThrowOnFailure(queryService.EndQuerySaveBatch());
            }            
        }
private void CheckoutFiles ( string [ ] filePaths ) { var queryService = ( IVsQueryEditQuerySave2 ) this . serviceProvider . GetService ( typeof ( SVsQueryEditQuerySave ) ) ; if ( queryService == null ) { return ; } uint editInfo ; uint editResult ; ErrorHandler . ThrowOnFailure ( queryService . QueryEditFiles ( ( uint ) tagVSQueryEditFlags . QEF_DisallowInMemoryEdits , filePaths . Length , filePaths , null , null , out editResult , out editInfo ) ) ; if ( editResult == ( uint ) tagVSQueryEditResult . QER_EditOK ) { return ; } if ( editResult == ( uint ) tagVSQueryEditResult . QER_NoEdit_UserCanceled && ( editInfo & ( uint ) tagVSQueryEditResultFlags . QER_CheckoutCanceledOrFailed ) == ( uint ) tagVSQueryEditResultFlags . QER_CheckoutCanceledOrFailed ) { throw CheckoutAbortedException ( ) ; } ErrorHandler . ThrowOnFailure ( queryService . BeginQuerySaveBatch ( ) ) ; try { uint saveResult ; ErrorHandler . ThrowOnFailure ( queryService . QuerySaveFiles ( 0 , filePaths . Length , filePaths , null , null , out saveResult ) ) ; if ( saveResult != ( uint ) tagVSQuerySaveResult . QSR_SaveOK ) { throw CheckoutAbortedException ( ) ; } } finally { ErrorHandler . ThrowOnFailure ( queryService . EndQuerySaveBatch ( ) ) ; } }
Uses the  service to checkout specified files with a minimum number of visual prompts.
Uses the service to checkout specified files with a minimum number of visual prompts .
// SVsQueryEditQueryService is not available, don't try to check out files. // Call QueryEditFiles to perform the action specified in the Source Control/Editing setting of the Visual Studio Options dialog. // Although, technically, we are not "editing" the generated files, we call this method because, unlike QuerySaveFiles, it displays  // a single visual prompt for all files that need to be checked out. // If QueryEditFiles did not allow us to modify the generated files, call QuerySaveFiles to perform the action specified in the  // Source Control/Saving setting of the Visual Studio Options dialog.             // Allow the user to cancel check-out-on-save for all files in the batch
filePaths
string[]