internal bool QueryEditProjectFile(bool suppressUI)
{
bool result = true;
if (this.site == null)
{
// We're already zombied. Better return FALSE.
result = false;
}
else if (this.disableQueryEdit)
{
return true;
}
else
{
IVsQueryEditQuerySave2 queryEditQuerySave = this.GetService(typeof(SVsQueryEditQuerySave)) as IVsQueryEditQuerySave2;
if (queryEditQuerySave != null)
{ // Project path dependends on server/client project
string path = this.filename;
tagVSQueryEditFlags qef = tagVSQueryEditFlags.QEF_AllowInMemoryEdits;
if (suppressUI)
qef |= tagVSQueryEditFlags.QEF_SilentMode;
// If we are debugging, we want to prevent our project from being reloaded. To
// do this, we pass the QEF_NoReload flag
if (!Utilities.IsVisualStudioInDesignMode(this.Site))
qef |= tagVSQueryEditFlags.QEF_NoReload;
uint verdict;
uint moreInfo;
string[] files = new string[1];
files[0] = path;
uint[] flags = new uint[1];
VSQEQS_FILE_ATTRIBUTE_DATA[] attributes = new VSQEQS_FILE_ATTRIBUTE_DATA[1];
int hr = queryEditQuerySave.QueryEditFiles(
(uint)qef,
1, // 1 file
files, // array of files
flags, // no per file flags
attributes, // no per file file attributes
out verdict,
out moreInfo /* ignore additional results */);
tagVSQueryEditResult qer = (tagVSQueryEditResult)verdict;
if (ErrorHandler.Failed(hr) || (qer != tagVSQueryEditResult.QER_EditOK))
{
if (!suppressUI && !Utilities.IsInAutomationFunction(this.Site))
{
string message = SR.GetString(SR.CancelQueryEdit, path);
string title = string.Empty;
OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL;
OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK;
OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
VsShellUtilities.ShowMessageBox(this.Site, title, message, icon, buttons, defaultButton);
}
result = false;
}
}
}
return result;
}