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


C# DTE2.GetObject方法代码示例

本文整理汇总了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();
        }
开发者ID:tommck,项目名称:TfsSolutionInfo,代码行数:21,代码来源:TfsProjectInfoPackage.cs

示例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);
        }
开发者ID:StanleyGoldman,项目名称:TeamPilgrim,代码行数:24,代码来源:TeamPilgrimVsService.cs

示例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;
 }
开发者ID:san90279,项目名称:UK_OAS,代码行数:8,代码来源:fmNewEmptySolution.cs

示例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
//.........这里部分代码省略.........
开发者ID:jsvasani,项目名称:TFSHistorySearch,代码行数:101,代码来源:TfsHelper.cs


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