当前位置: 首页>>代码示例>>C#>>正文


C# EnvDTE.Open方法代码示例

本文整理汇总了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;
		}
开发者ID:cjheath,项目名称:NORMA,代码行数:73,代码来源:ORMExtensionManager.cs


注:本文中的EnvDTE.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。