本文整理汇总了C#中DTE2.GetObject方法的典型用法代码示例。如果您正苦于以下问题:C# DTE2.GetObject方法的具体用法?C# DTE2.GetObject怎么用?C# DTE2.GetObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DTE2
的用法示例。
在下文中一共展示了DTE2.GetObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TfsProjectInfoPackage
/// <summary>
/// Default constructor of the package.
/// Inside this method you can place any initialization code that does not require
/// any Visual Studio service because at this point the package object is created but
/// not sited yet inside Visual Studio environment. The place to do all the other
/// initialization is the Initialize method.
/// </summary>
public TfsProjectInfoPackage()
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
_extensibility = (IVsExtensibility)Package.GetGlobalService(typeof(IVsExtensibility));
_dte2 = (DTE2)_extensibility.GetGlobalsObject(null).DTE;
_vcExt = _dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
// The SolutionEvents is an *instance* variable that must be kept around for the events to work!
_solutionEvents = _dte2.Events.SolutionEvents;
_solutionEvents.Opened += () => ReadSolutionInfo();
_solutionEvents.AfterClosing += () => ReadSolutionInfo();
}
示例2: TeamPilgrimVsService
public TeamPilgrimVsService(TeamPilgrimPackage packageInstance, IVsUIShell vsUiShell, DTE2 dte2, IVsSolution vsSolution)
{
_teamFoundationBuild = new Lazy<VsTeamFoundationBuildWrapper>(() => new VsTeamFoundationBuildWrapper(_packageInstance.GetPackageService<IVsTeamFoundationBuild>()));
_portalSettingsLauncher = new Lazy<IPortalSettingsLauncher>(() => _packageInstance.GetPackageService<IPortalSettingsLauncher>());
_sourceControlSettingsLauncher = new Lazy<ISourceControlSettingsLauncher>(() => _packageInstance.GetPackageService<ISourceControlSettingsLauncher>());
_processTemplateManagerLauncher = new Lazy<IProcessTemplateManagerLauncher>(() => _packageInstance.GetPackageService<IProcessTemplateManagerLauncher>());
_workItemTrackingPackage = new Lazy<WorkItemTrackingPackageWrapper>();
_versionControlPackage = new Lazy<VersionControlPackageWrapper>();
_querySecurityCommandHelpers = new Lazy<QuerySecurityCommandHelpersWrapper>();
_pendingChangesPageViewModelUtilsWrapper = new Lazy<PendingChangesPageViewModelUtilsWrapper>();
VsUiShell = vsUiShell;
_packageInstance = packageInstance;
Dte2 = dte2;
VsSolution = vsSolution;
VersionControlExt = dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
TeamFoundationServerExt = dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt") as TeamFoundationServerExt;
WorkItemTrackingDocumentService = new DocumentServiceWrapper(dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.DocumentService") as DocumentService);
var teamFoundationHostObject = (ITeamFoundationContextManager)TeamFoundationServerExt_TeamFoundationHostField.Value.GetValue(TeamFoundationServerExt);
TeamFoundationHost = new TeamFoundationHostWrapper(teamFoundationHostObject);
vsSolution.AdviseSolutionEvents(this, out _adviseSolutionEventsCookie);
}
示例3: AddWebSite
private static void AddWebSite(DTE2 aDTE, String WebFolderPath)
{
String Path = WebFolderPath;
VsWebSite.VSWebPackage webPackage = aDTE.GetObject("WebPackage") as VsWebSite.VSWebPackage;
EnvDTE.Project proj = webPackage.OpenWebSite(Path,
VsWebSite.OpenWebsiteOptions.OpenWebsiteOption_None, true);
String str = string.Empty;
}
示例4: GetServerUriAndItemPath
/// <summary>
/// Gets the server Uri and the path of the selected item
/// </summary>
/// <param name="appObj">Application object</param>
/// <param name="serverUri">Server Uri</param>
/// <param name="itemPath">Item path</param>
/// <param name="isFolder">True if the selected item is a folder</param>
public static void GetServerUriAndItemPath(DTE2 appObj, out string serverUri, out string itemPath, out bool isFolder)
{
if (appObj == null)
throw new ArgumentNullException("appObj");
isFolder = false;
// Get local workspace info
WorkspaceInfo[] wsInfo = Workstation.Current.GetAllLocalWorkspaceInfo();
if (wsInfo.Length == 0)
throw new TfsHistorySearchException("No workspace found.");
// Get server Uri
serverUri = wsInfo[0].ServerUri.AbsoluteUri;
//if Active Window is Source Control Explorer
if (appObj.ActiveWindow != null && appObj.ActiveWindow.Type == vsWindowType.vsWindowTypeToolWindow
&& appObj.ActiveWindow.ObjectKind == "{99B8FA2F-AB90-4F57-9C32-949F146F1914}")
{
VersionControlExt vce;
// The top level class used to access all other Team Foundation Version Control Extensiblity classes
vce = appObj.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
if (!vce.Explorer.Connected)
{
throw new TfsHistorySearchException("Source control explorer is not connected to a Team Foundation Server.");
}
// Get all selected items
VersionControlExplorerItem[] selectedItems = vce.Explorer.SelectedItems;
if (selectedItems.Length > 1)
throw new TfsHistorySearchException("Multiple items selected. Please select only one item.");
//Take the 1st item
itemPath = selectedItems[0].SourceServerPath;
isFolder = selectedItems[0].IsFolder;
}
//if Active Window is Solution Explorer
else if (appObj.ActiveWindow != null && appObj.ActiveWindow.Type == vsWindowType.vsWindowTypeSolutionExplorer)
{
isFolder = false;
if (appObj.SelectedItems.MultiSelect == true)
throw new TfsHistorySearchException("Multiple items selected. Please select only one item.");
SelectedItem selectedItem = appObj.SelectedItems.Item(1);
if (selectedItem.ProjectItem != null)
{
//Its a project file
string fileName = selectedItem.ProjectItem.Properties.Item("URL").Value.ToString();
fileName = Regex.Replace(fileName, "file:///", String.Empty, RegexOptions.IgnoreCase);
if (fileName.EndsWith("\\"))
{
fileName = fileName.Substring(0, fileName.LastIndexOf('\\'));
isFolder = true;
}
try
{
// Get a reference to the Team Foundation Server.
TfsTeamProjectCollection tc = new TfsTeamProjectCollection(wsInfo[0].ServerUri);
VersionControlServer vcs = tc.GetService(typeof(VersionControlServer)) as VersionControlServer;
Item item = vcs.GetItem(fileName);
itemPath = item.ServerItem;
}
catch (Exception ex)
{
throw new TfsHistorySearchException("Item not under source control.", ex);
}
}
else if (selectedItem.Project != null)
{
//Its a project
string fileName = selectedItem.Project.FileName;
try
{
// Get a reference to the Team Foundation Server.
TfsTeamProjectCollection tc = new TfsTeamProjectCollection(wsInfo[0].ServerUri);
VersionControlServer vcs = tc.GetService(typeof(VersionControlServer)) as VersionControlServer;
Item item = vcs.GetItem(fileName);
itemPath = item.ServerItem;
}
catch (Exception ex)
{
throw new TfsHistorySearchException("Item not under source control.", ex);
}
}
else
{
//check if .sln is selected
if (appObj.ToolWindows != null && appObj.ToolWindows.SolutionExplorer != null && appObj.ToolWindows.SolutionExplorer.SelectedItems != null
&& ((object[])appObj.ToolWindows.SolutionExplorer.SelectedItems).Length > 0
//.........这里部分代码省略.........