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


C# IVsHierarchy.GetSite方法代码示例

本文整理汇总了C#中IVsHierarchy.GetSite方法的典型用法代码示例。如果您正苦于以下问题:C# IVsHierarchy.GetSite方法的具体用法?C# IVsHierarchy.GetSite怎么用?C# IVsHierarchy.GetSite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IVsHierarchy的用法示例。


在下文中一共展示了IVsHierarchy.GetSite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SelectItem

        private static int SelectItem(IVsHierarchy hierarchy, string filter, string title, string preselectedItem, out string appRelUrlOfSelectedItem, out bool canceled)
        {
            appRelUrlOfSelectedItem = null;
            canceled = false;
            int hr = NativeMethods.E_FAIL;

            if (hierarchy != null)
            {
                IOleServiceProvider site = null;
                hr = hierarchy.GetSite(out site);
                if (NativeMethods.Succeeded(hr) && site != null)
                {
                    IProjectItemSelector selector = site.CreateSitedInstance<IProjectItemSelector>(typeof(IProjectItemSelector_Class).GUID);
                    if (selector != null)
                    {
                        hr = selector.SelectItem(
                            hierarchy,
                            VSConstants.VSITEMID_NIL,
                            filter,
                            title,
                            ProjectItemSelectorFlags.PISF_ReturnAppRelativeUrls,
                            null,
                            preselectedItem,
                            null,
                            out appRelUrlOfSelectedItem,
                            out canceled);
                    }
                }
            }

            return hr;
        }
开发者ID:TomDu,项目名称:lab,代码行数:32,代码来源:ProjectItemSelector.cs

示例2: VsSolutionHierarchyNode

      internal VsSolutionHierarchyNode(IVsHierarchy hierarchy, uint itemId, Lazy<VsSolutionHierarchyNode> parent)
      {
         if (hierarchy == null)
            throw new ArgumentNullException(nameof(hierarchy), $"{nameof(hierarchy)} is null.");

         VsHierarchy = hierarchy;
         ItemId = itemId;

         IntPtr nestedHierarchyObj;
         uint nestedItemId;
         Guid hierGuid = typeof(IVsHierarchy).GUID;

         // Check first if this node has a nested hierarchy. If so, then there really are two 
         // identities for this node: 1. hierarchy/itemid 2. nestedHierarchy/nestedItemId.
         // We will recurse and call EnumHierarchyItems which will display this node using
         // the inner nestedHierarchy/nestedItemId identity.
         int hr = hierarchy.GetNestedHierarchy(itemId, ref hierGuid, out nestedHierarchyObj, out nestedItemId);
         if (hr == VSConstants.S_OK && nestedHierarchyObj != IntPtr.Zero)
         {
            IVsHierarchy nestedHierarchy = Marshal.GetObjectForIUnknown(nestedHierarchyObj) as IVsHierarchy;
            Marshal.Release(nestedHierarchyObj); // we are responsible to release the refcount on the out IntPtr parameter
            if (nestedHierarchy != null)
            {
               VsHierarchy = nestedHierarchy;
               ItemId = nestedItemId;
            }
         }
                  
         DisplayName = VsHierarchy.GetProperty<string>(__VSHPROPID.VSHPROPID_Name, ItemId);

         m_parent = parent ?? new Lazy<VsSolutionHierarchyNode>(() =>
         {
            if (VsHierarchy is IVsSolution)
               return null;

            var rootHierarchy = hierarchy.GetProperty<IVsHierarchy>(__VSHPROPID.VSHPROPID_ParentHierarchy, VSConstants.VSITEMID_ROOT);
            if (rootHierarchy == null)
               return null;

            var rootNode = new VsSolutionHierarchyNode(rootHierarchy, VSConstants.VSITEMID_ROOT);

            var parentNode = new VsSolutionHierarchyNode[] { rootNode }
                .Concat(rootNode.Children.BreadthFirstTraversal(node => node.Children))
                .FirstOrDefault(node => node.Children.Any(child => child.ItemId == ItemId));

            if (parentNode == null)
               return null;

            return new VsSolutionHierarchyNode(parentNode.VsHierarchy, parentNode.ItemId);
         });

         this.m_serviceProvider = new Lazy<IServiceProvider>(() =>
         {
            Microsoft.VisualStudio.OLE.Interop.IServiceProvider oleSp;
            hierarchy.GetSite(out oleSp);
            return oleSp != null ?
                new ServiceProvider(oleSp) :
                GlobalVsServiceProvider.Instance;
         });
      }
开发者ID:modulexcite,项目名称:AlphaVSX,代码行数:60,代码来源:VsSolutionHierarchyNode.cs

示例3: CreateErrorTask

        internal static ErrorTask CreateErrorTask(
            string document, string errorMessage, TextSpan textSpan, TaskErrorCategory taskErrorCategory, IVsHierarchy hierarchy,
            uint itemID, MARKERTYPE markerType)
        {
            ErrorTask errorTask = null;

            IOleServiceProvider oleSp = null;
            hierarchy.GetSite(out oleSp);
            IServiceProvider sp = new ServiceProvider(oleSp);

            // see if Document is open
            IVsTextLines buffer = null;
            var docData = VSHelpers.GetDocData(sp, document);
            if (docData != null)
            {
                buffer = VSHelpers.GetVsTextLinesFromDocData(docData);
            }

            if (buffer != null)
            {
                errorTask = new EFModelDocumentTask(sp, buffer, markerType, textSpan, document, itemID, errorMessage, hierarchy);
                errorTask.ErrorCategory = taskErrorCategory;
            }
            else
            {
                errorTask = new EFModelErrorTask(
                    document, errorMessage, textSpan.iStartLine, textSpan.iEndLine, taskErrorCategory, hierarchy, itemID);
            }

            return errorTask;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:31,代码来源:EFModelErrorTaskFactory.cs

示例4: ServiceProvider

		///-------------------------------------------------------------------------------------------------------------
		/// <summary>
		///	 Initializes the generator state.
		/// </summary>
		///-------------------------------------------------------------------------------------------------------------
		void IVsCodeBehindCodeGenerator.Initialize(IVsHierarchy hierarchy)
		{
			IOleServiceProvider serviceProvider = null;
			_hierarchy = hierarchy;
			_hierarchy.GetSite(out serviceProvider);
			_serviceProvider = new ServiceProvider(serviceProvider);
			_codeGeneratorOptions = new CodeGeneratorOptions();
			_codeGeneratorOptions.BlankLinesBetweenMembers = false;
		}
开发者ID:xenocons,项目名称:visualfsharp,代码行数:14,代码来源:CodeBehindCodeGenerator.cs

示例5: GetServiceLocator

		public IServiceLocator GetServiceLocator (IVsHierarchy hierarchy)
		{
			Guard.NotNull (nameof (hierarchy), hierarchy);

			IServiceProvider services;
			Ole.IServiceProvider site;
			if (ErrorHandler.Failed (hierarchy.GetSite (out site)))
				services = Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider;
			else
				services = new Microsoft.VisualStudio.Shell.ServiceProvider (site);

			return new ServiceLocatorImpl (services);
		}
开发者ID:kzu,项目名称:clide,代码行数:13,代码来源:ServiceLocatorProvider.cs

示例6: IDEBuildLogger

        /// <summary>
        /// Constructor.  Inititialize member data.
        /// </summary>
        public IDEBuildLogger(IVsOutputWindowPane output, TaskProvider taskProvider, IVsHierarchy hierarchy)
        {
            if (taskProvider == null)
                throw new ArgumentNullException("taskProvider");
            if (hierarchy == null)
                throw new ArgumentNullException("hierarchy");

            this.taskProvider = taskProvider;
            this.outputWindowPane = output;
            this.hierarchy = hierarchy;
            IOleServiceProvider site;
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(hierarchy.GetSite(out site));
            this.serviceProvider = new ServiceProvider(site);
        }
开发者ID:Jeremiahf,项目名称:wix3,代码行数:17,代码来源:idebuildlogger.cs

示例7: VsSolutionHierarchyNode

        internal VsSolutionHierarchyNode(IVsHierarchy hierarchy, uint itemId, Lazy<VsSolutionHierarchyNode> parent)
        {
            Guard.NotNull(() => hierarchy, hierarchy);

            this.VsHierarchy = hierarchy;
            this.ItemId = itemId;

            IntPtr nestedHierarchyObj;
            uint nestedItemId;
            Guid hierGuid = typeof(IVsHierarchy).GUID;

            int hr = hierarchy.GetNestedHierarchy(this.ItemId, ref hierGuid, out nestedHierarchyObj, out nestedItemId);
            if (hr == VSConstants.S_OK && nestedHierarchyObj != IntPtr.Zero)
            {
                IVsHierarchy nestedHierarchy = Marshal.GetObjectForIUnknown(nestedHierarchyObj) as IVsHierarchy;
                Marshal.Release(nestedHierarchyObj);
                if (nestedHierarchy != null)
                {
                    this.VsHierarchy = nestedHierarchy;
                    this.ItemId = nestedItemId;
                }
            }

            this.extensibilityObject = new Lazy<object>(() => this.VsHierarchy.Properties(this.ItemId).ExtenderObject);
            this.serviceProvider = new Lazy<IServiceProvider>(() =>
            {
                Microsoft.VisualStudio.OLE.Interop.IServiceProvider oleSp;
                hierarchy.GetSite(out oleSp);
                return oleSp != null ?
                    new ServiceProvider(oleSp) :
                    GlobalServiceProvider.Instance;
            });

            this.DisplayName = this.VsHierarchy.Properties(this.ItemId).DisplayName;
            this.parent = parent ?? new Lazy<VsSolutionHierarchyNode>(() =>
            {
                if (this.VsHierarchy is IVsSolution)
                    return null;

                // Implement this property so that it iterates each and every node finding 
                // the parent.
				var parentItem = this.VsHierarchy.Properties(this.ItemId).Parent;
				if (parentItem == null)
					return null;

				return new VsSolutionHierarchyNode(parentItem.Hierarchy, parentItem.ItemId);
            });
        }
开发者ID:MobileEssentials,项目名称:clide,代码行数:48,代码来源:VsSolutionHierarchyNode.cs

示例8: GetProjectServiceProvider

        /// <summary>
        /// Gets the project service provider.
        /// </summary>
        /// <param name="hierarchy">The hierarchy.</param>
        /// <returns></returns>
        public static IServiceProvider GetProjectServiceProvider(IVsHierarchy hierarchy)
        {
            if (hierarchy == null)
            {
                throw new ArgumentNullException("hierarchy");
            }

            Microsoft.VisualStudio.OLE.Interop.IServiceProvider oleProvider;
            if (hierarchy.GetSite(out oleProvider) >= 0)
            {
                return new ServiceProvider(oleProvider);
            }
            else
            {
                throw new ArgumentException(Properties.Resources.HierarchyNotSitedException, "hierarchy");
            }
        }
开发者ID:riseandcode,项目名称:open-wscf-2010,代码行数:22,代码来源:VsHelper.cs

示例9: IDEBuildLogger

        /// <summary>
        /// Constructor.  Inititialize member data.
        /// </summary>
        public IDEBuildLogger(IVsOutputWindowPane output, TaskProvider taskProvider, IVsHierarchy hierarchy)
        {
            if (taskProvider == null)
                throw new ArgumentNullException("taskProvider");
            if (hierarchy == null)
                throw new ArgumentNullException("hierarchy");

            Trace.WriteLineIf(Thread.CurrentThread.GetApartmentState() != ApartmentState.STA, "WARNING: IDEBuildLogger constructor running on the wrong thread.");

            IOleServiceProvider site;
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(hierarchy.GetSite(out site));

            this.taskProvider = taskProvider;
            this.outputWindowPane = output;
            this.hierarchy = hierarchy;
            this.serviceProvider = new ServiceProvider(site);
            this.dispatcher = Dispatcher.CurrentDispatcher;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:21,代码来源:IDEBuildLogger.cs

示例10: using

        int IVsEditorFactoryNotify.NotifyItemAdded(uint grfEFN, IVsHierarchy pHier, uint itemid, string pszMkDocument)
        {
            object o;
            var hr = pHier.GetProperty(itemid, (int)__VSHPROPID.VSHPROPID_ExtObject, out o);

            if (NativeMethods.Succeeded(hr))
            {
                var projectItem = o as ProjectItem;
                if (projectItem != null
                    && VsUtils.EntityFrameworkSupportedInProject(projectItem.ContainingProject, ServiceProvider, allowMiscProject: false))
                {
                    if (EdmUtils.IsDataServicesEdmx(projectItem.get_FileNames(1)))
                    {
                        // if the EDMX has a data services node, don't add the SingleFileGenerator, etc.
                        return VSConstants.S_OK;
                    }

                    IOleServiceProvider oleSP;
                    pHier.GetSite(out oleSP);
                    using (var sp = new ServiceProvider(oleSP))
                    {
                        var appType = VsUtils.GetApplicationType(sp, projectItem.ContainingProject);

                        // set the project item properties
                        SetProjectItemProperties(projectItem, appType);
                    }

                    if (grfEFN != (uint)__EFNFLAGS.EFN_ClonedFromTemplate)
                    {
                        // we're not adding from template i.e. Add Existing Item
                        var referenceFileNames = GetReferencesFromTemplateForProject(projectItem.ContainingProject);
                        AddMissingReferences(projectItem, referenceFileNames);
                        AddBuildProvider(projectItem);
                    }
                }
            }

            return VSConstants.S_OK;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:39,代码来源:MicrosoftDataEntityDesignEditorFactory.cs

示例11: XmlModelErrorTask

        protected XmlModelErrorTask(
            string document, string errorMessage, int lineNumber, int columnNumber, TaskErrorCategory category, IVsHierarchy hierarchy,
            uint itemID)
        {
            ErrorCategory = category;
            HierarchyItem = hierarchy;
            _itemID = itemID;

            IOleServiceProvider oleSP = null;
            var hr = hierarchy.GetSite(out oleSP);
            if (NativeMethods.Succeeded(hr))
            {
                _serviceProvider = new ServiceProvider(oleSP);
            }

            Debug.Assert(!String.IsNullOrEmpty(document), "document is null or empty");
            Debug.Assert(!String.IsNullOrEmpty(errorMessage), "errorMessage is null or empty");
            Debug.Assert(hierarchy != null, "hierarchy is null");

            Document = document;
            Text = errorMessage;
            Line = lineNumber;
            Column = columnNumber;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:24,代码来源:XmlModelErrorTask.cs

示例12: PreviewTransform

        private void PreviewTransform(IVsHierarchy hier, string sourceFile, string transformFile)
        {
            if (string.IsNullOrWhiteSpace(sourceFile)) { throw new ArgumentNullException("sourceFile"); }
            if (string.IsNullOrWhiteSpace(transformFile)) { throw new ArgumentNullException("transformFile"); }
            if (!File.Exists(sourceFile)) { throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.Error_SourceFileNotFound, sourceFile), sourceFile); }
            if (!File.Exists(transformFile)) { throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.Error_TransformFileNotFound, transformFile), transformFile); }

            // Get our options
            using (OptionsDialogPage optionsPage = new OptionsDialogPage()) {
                optionsPage.LoadSettingsFromStorage();
                
                this.LogMessageWriteLineFormat("SlowCheetah PreviewTransform");
                FileInfo sourceFileInfo = new FileInfo(sourceFile);
                // dest file
                string destFile = this.GetTempFilename(true, sourceFileInfo.Extension);

                // perform the transform and then display the result into the diffmerge tool that comes with VS. If for 
                // some reason we can't find it, we just open it in an editor window
                ITransformer transformer = new Transformer();
                transformer.Transform(sourceFile, transformFile, destFile);

                // Does the customer want a preview?
                if (optionsPage.EnablePreview == false) {
                    GetDTE().ItemOperations.OpenFile(destFile);
                }
                else
                {
                    Guid SID_SVsDifferenceService = new Guid("{77115E75-EF9E-4F30-92F2-3FE78BCAF6CF}");
                    Guid IID_IVsDifferenceService = new Guid("{E20E53BE-8B7A-408F-AEA7-C0AAD6D1B946}");
                    uint VSDIFFOPT_RightFileIsTemporary = 0x00000020;   //The right file is a temporary file explicitly created for diff.

                    // If the diffmerge service is available (dev11) and no diff tool is specified, or diffmerge.exe is specifed we use the service
                    IOleServiceProvider sp;
                    hier.GetSite(out sp);
                    IntPtr diffSvcIntPtr = IntPtr.Zero;
                    int hr = sp.QueryService(ref SID_SVsDifferenceService, ref IID_IVsDifferenceService, out diffSvcIntPtr);
                    if(diffSvcIntPtr != IntPtr.Zero && (string.IsNullOrEmpty(optionsPage.PreviewToolExecutablePath) || optionsPage.PreviewToolExecutablePath.EndsWith(@"\diffmerge.exe", StringComparison.OrdinalIgnoreCase)))
                    {
                        try {
                            object diffSvc = Marshal.GetObjectForIUnknown(diffSvcIntPtr);
                            Type t = diffSvc.GetType();
                            Type[] paramTypes = new Type[] {typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(uint)};
                            MethodInfo openComparisonWindow2 = t.GetMethod("OpenComparisonWindow2", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, paramTypes, null);
                            Debug.Assert(openComparisonWindow2 != null);
                            if(openComparisonWindow2 != null)
                            {
                                string sourceName = Path.GetFileName(sourceFile);
                                string leftLabel = string.Format(CultureInfo.CurrentCulture,  Resources.TransformPreview_LeftLabel, sourceName);
                                string rightLabel = string.Format(CultureInfo.CurrentCulture, Resources.TransformPreview_RightLabel, sourceName, Path.GetFileName(transformFile));
                                string caption = string.Format(CultureInfo.CurrentCulture, Resources.TransformPreview_Caption, sourceName);
                                string tooltip = string.Format(CultureInfo.CurrentCulture, Resources.TransformPreview_ToolTip, sourceName);
                                object[] paras = new object[] {sourceFile, destFile,  caption, tooltip, leftLabel, rightLabel, null, null, VSDIFFOPT_RightFileIsTemporary};
                                openComparisonWindow2.Invoke(diffSvc, paras);
                            }
                        }
                        finally {
                            Marshal.Release(diffSvcIntPtr);
                        }
                    }
                    else if (string.IsNullOrEmpty(optionsPage.PreviewToolExecutablePath))
                    {
                        throw new FileNotFoundException(Resources.Error_NoPreviewToolSpecified);
                    }
                    else if (!File.Exists(optionsPage.PreviewToolExecutablePath))
                    {
                        throw new FileNotFoundException(string.Format(Resources.Error_CantFindPreviewTool, optionsPage.PreviewToolExecutablePath), optionsPage.PreviewToolExecutablePath);
                    }
                    else
                    {
                        // Quote the filenames...
                        ProcessStartInfo psi = new ProcessStartInfo(optionsPage.PreviewToolExecutablePath, string.Format(optionsPage.PreviewToolCommandLine, "\"" + sourceFile + "\"", "\"" + destFile + "\""));
                        psi.CreateNoWindow = true;
                        psi.UseShellExecute = false;
                        Process.Start(psi);
                    }
                }
            }

            // TODO: Instead of creating a file and then deleting it later we could instead do this
            //          http://matthewmanela.com/blog/the-problem-with-the-envdte-itemoperations-newfile-method/
            //          http://social.msdn.microsoft.com/Forums/en/vsx/thread/eb032063-eb4d-42e0-84e8-dec64bf42abf
        }
开发者ID:VirtueMe,项目名称:slow-cheetah,代码行数:82,代码来源:SlowCheetahPackage.cs

示例13: IDEBuildLogger

        /// <summary>
        /// Constructor.  Inititialize member data.
        /// </summary>
        public IDEBuildLogger(IVsOutputWindowPane output, TaskProvider taskProvider, IVsHierarchy hierarchy)
        {
            UIThread.MustBeCalledFromUIThread();

            Utilities.ArgumentNotNull("taskProvider", taskProvider);
            Utilities.ArgumentNotNull("hierarchy", hierarchy);

            Trace.WriteLineIf(Thread.CurrentThread.GetApartmentState() != ApartmentState.STA, "WARNING: IDEBuildLogger constructor running on the wrong thread.");

            IOleServiceProvider site;
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(hierarchy.GetSite(out site));

            this.taskProvider = taskProvider;
            this.outputWindowPane = output;
            this.hierarchy = hierarchy;
            this.serviceProvider = new ServiceProvider(site);
            this.dispatcher = Dispatcher.CurrentDispatcher;
        }
开发者ID:baodehua,项目名称:VisualRust,代码行数:21,代码来源:IDEBuildLogger.cs

示例14: GetArtifactForValidation

        private static EFArtifact GetArtifactForValidation(Uri uri, IVsHierarchy hierarchy, ModelManager modelManager)
        {
            IServiceProvider oleServiceProvider = null;
            var modelListener = PackageManager.Package.ModelChangeEventListener;
            hierarchy.GetSite(out oleServiceProvider);
            System.IServiceProvider sp = new ServiceProvider(oleServiceProvider);
            var escherDocData = VSHelpers.GetDocData(sp, uri.LocalPath) as IEntityDesignDocData;

            EFArtifact artifact = null;
            //
            // If we opened the document with Escher, then use the XmlEditor's xlinq tree
            // If we opened the document with the xml editor, but not escher, then 
            // we don't want to use the XmlEditor's xlinq tree, because then we would be receiving events when
            // the document changes, and we currently don't support that.
            //

            if (escherDocData != null)
            {
                artifact = PackageManager.Package.ModelManager.GetNewOrExistingArtifact(
                    uri, new VSXmlModelProvider(PackageManager.Package, PackageManager.Package));
                if (modelListener != null)
                {
                    modelListener.OnBeforeValidateModel(VSHelpers.GetProject(hierarchy), artifact, true);
                }
            }
            else
            {
                if (Path.GetExtension(uri.LocalPath).Equals(EntityDesignArtifact.ExtensionEdmx, StringComparison.OrdinalIgnoreCase))
                {
                    // no doc data exists for this document, so load it into a temp model manager that can be disposed of when we're done. 
                    // Using the LoaderBasedXmlModelProvider will let us catch XML scanner and parser errors (the xml editor will try to 
                    // recover from these, and we won't know that the problem occurred. 
                    artifact = modelManager.GetNewOrExistingArtifact(uri, new StandaloneXmlModelProvider(PackageManager.Package));
                    if (modelListener != null)
                    {
                        modelListener.OnBeforeValidateModel(VSHelpers.GetProject(hierarchy), artifact, true);
                    }
                }
            }

            return artifact;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:42,代码来源:VisualStudioEdmxValidator.cs

示例15: GetProjectServiceProvider

		public static IServiceProvider GetProjectServiceProvider(IVsHierarchy hierarchy)
		{
			if (hierarchy == null) throw new ArgumentNullException("hierarchy");
			
			Microsoft.VisualStudio.OLE.Interop.IServiceProvider oleProvider;
			if (hierarchy.GetSite(out oleProvider) >= 0)
			{
				return new ServiceProvider(oleProvider);
			}
			else
			{
				throw new ArgumentException("Hierarchy is not sited.");
			}
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:14,代码来源:VsHelper.cs


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