Exemplo n.º 1
0
        protected virtual IVsReferenceProviderContext CreateFileReferenceProviderContext(IVsReferenceManager mgr)
        {
            var exts = AddReferenceExtensions;

            if (string.IsNullOrEmpty(exts))
            {
                return(null);
            }

            var context = (IVsFileReferenceProviderContext)mgr.CreateProviderContext(VSConstants.FileReferenceProvider_Guid);

            context.BrowseFilter = AddReferenceExtensions.Replace('|', '\0') + "\0";

            var referenceContainer = this.GetReferenceContainer();
            var references         = referenceContainer
                                     .EnumReferences()
                                     .Where(n => !(n is AssemblyReferenceNode) && !(n is ProjectReferenceNode));

            foreach (var reference in references)
            {
                var newReference = (IVsFileReference)context.CreateReference();
                newReference.FullPath          = reference.Url;
                newReference.AlreadyReferenced = true;
                context.AddReference(newReference);
            }

            return(context);
        }
Exemplo n.º 2
0
        protected virtual IVsReferenceProviderContext CreateAssemblyReferenceProviderContext(IVsReferenceManager mgr)
        {
            var moniker = TargetFrameworkMoniker.FullName;

            if (string.IsNullOrEmpty(moniker))
            {
                return(null);
            }

            var context = (IVsAssemblyReferenceProviderContext)mgr.CreateProviderContext(VSConstants.AssemblyReferenceProvider_Guid);

            context.TargetFrameworkMoniker = moniker;
            context.AssemblySearchPaths    = AssemblySearchPaths;

            var referenceContainer = this.GetReferenceContainer();
            var references         = referenceContainer
                                     .EnumReferences()
                                     .OfType <AssemblyReferenceNode>();

            foreach (var reference in references)
            {
                var newReference = (IVsAssemblyReference)context.CreateReference();
                newReference.FullPath          = reference.Url ?? reference.AssemblyName.ToString();
                newReference.Name              = reference.AssemblyName.Name;
                newReference.AlreadyReferenced = true;
                context.AddReference(newReference);
            }

            return(context);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called by the ReferenceManagerDialog to determine what contexts to show in the UI.
        /// </summary>
        public Array GetProviderContexts()
        {
            // Return just the File provider context so that just the browse tab shows up.
            var context = _referenceManager.CreateProviderContext(VSConstants.FileReferenceProvider_Guid) as IVsFileReferenceProviderContext;

            context.BrowseFilter = string.Format("{0} (*.dll)\0*.dll\0", SolutionExplorerShim.AnalyzerFiles);
            return(new[] { context });
        }
Exemplo n.º 4
0
        protected virtual IVsReferenceProviderContext CreateProjectReferenceProviderContext(IVsReferenceManager mgr)
        {
            var context = (IVsProjectReferenceProviderContext)mgr.CreateProviderContext(VSConstants.ProjectReferenceProvider_Guid);

            context.CurrentProject = this;

            var referenceContainer = this.GetReferenceContainer();
            var references         = referenceContainer
                                     .EnumReferences()
                                     .OfType <ProjectReferenceNode>();

            foreach (var reference in references)
            {
                var newReference = (IVsProjectReference)context.CreateReference();
                newReference.FullPath = reference.Url;
                newReference.Name     = reference.ReferencedProjectName;
                newReference.Identity = reference.ReferencedProjectGuid.ToString("B");
                newReference.ReferenceSpecification = reference.ReferencedProjectGuid.ToString();
                newReference.AlreadyReferenced      = true;
                context.AddReference(newReference);
            }

            return(context);
        }