本文整理汇总了C#中EnvDTE.Open方法的典型用法代码示例。如果您正苦于以下问题:C# EnvDTE.Open方法的具体用法?C# EnvDTE.Open怎么用?C# EnvDTE.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnvDTE
的用法示例。
在下文中一共展示了EnvDTE.Open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureExtensions
/// <summary>
/// Ensure that the current project item has the required extensions loaded.
/// This is only called after verifying that the current project item does
/// not satisfy the requirements.
/// </summary>
/// <param name="projectItem">The <see cref="EnvDTE.ProjectItem"/> to modify</param>
/// <param name="serviceProvider">The <see cref="IServiceProvider"/> for document tracking.</param>
/// <param name="extensions">An <see cref="T:ICollection{System.String}"/> of additional required extensions</param>
public static bool EnsureExtensions(EnvDTE.ProjectItem projectItem, IServiceProvider serviceProvider, ICollection<string> extensions)
{
ServiceProvider provider = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)projectItem.DTE);
// UNDONE: Localize message strings in here
if ((int)DialogResult.No == VsShellUtilities.ShowMessageBox(
provider,
"Additional extensions are required to support the chosen generators. Would you like to load the required extensions now?",
"ORM Generator Selection",
OLEMSGICON.OLEMSGICON_QUERY,
OLEMSGBUTTON.OLEMSGBUTTON_YESNO,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST))
{
return false;
}
EnvDTE.Document document = projectItem.Document;
bool secondPass = false;
bool tryDocument = true;
string itemPath = null;
while (tryDocument)
{
object documentExtensionManager;
MethodInfo methodInfo;
if (null != document &&
null != (documentExtensionManager = ORMCustomToolUtility.GetDocumentExtension<object>(document, "ORMExtensionManager", itemPath ?? (itemPath = projectItem.get_FileNames(0)), serviceProvider)) &&
null != (methodInfo = documentExtensionManager.GetType().GetMethod("EnsureExtensions", new Type[] { typeof(string[]) })))
{
string[] extensionsArray = new string[extensions.Count];
extensions.CopyTo(extensionsArray, 0);
methodInfo.Invoke(documentExtensionManager, new object[] { extensionsArray });
return true;
}
if (secondPass)
{
return false;
}
tryDocument = false;
secondPass = true;
// UNDONE: Localize message strings in here
if ((int)DialogResult.No == VsShellUtilities.ShowMessageBox(
provider,
"The .ORM file must be open in the default designer to add extensions. Would you like to open or reopen the document now?",
"ORM Generator Selection",
OLEMSGICON.OLEMSGICON_QUERY,
OLEMSGBUTTON.OLEMSGBUTTON_YESNO,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST))
{
return false;
}
if (document != null)
{
document.Close(EnvDTE.vsSaveChanges.vsSaveChangesPrompt);
document = projectItem.Document;
}
if (document == null)
{
projectItem.Open(Guid.Empty.ToString("B")).Visible = true;
document = projectItem.Document;
tryDocument = true;
}
}
return false;
}