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


C# IProject.As方法代码示例

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


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

示例1: AddReference

        /// <summary>
        /// Adds the given <paramref name="reference"/> project as a 
        /// project reference to <paramref name="project"/>.
        /// </summary>
        public static void AddReference(this IProject project, IProject reference)
        {
            if (project == null || reference == null)
                return;

            var dteProject = project.As<EnvDTE.Project>();

            if (dteProject == null)
                return;

            var vsProject = dteProject.Object as VSLangProj.VSProject;
            var dteReference = reference.As<EnvDTE.Project>();

            try
            {
                if (vsProject != null && dteReference != null)
                    vsProject.References.AddProject(dteReference);
            }
            catch (COMException)
            {
                // It's already there. Ignore.
            }
        }
开发者ID:slamj1,项目名称:ServiceMatrix,代码行数:27,代码来源:SolutionExtensions.cs

示例2: InstallNugetPackageForSpecifiedVersion

 private static void InstallNugetPackageForSpecifiedVersion(IProject project, IVsPackageInstaller vsPackageInstaller, string packageId, string version)
 {
     vsPackageInstaller.InstallPackage(
         ServiceMatrixOverrides.GetNugetFeedServiceBaseAddress() ?? "All",
         project.As<EnvDTE.Project>(),
         packageId,
         version,
         false);
 }
开发者ID:slamj1,项目名称:ServiceMatrix,代码行数:9,代码来源:SolutionExtensions.cs

示例3: InstallLatestNugetPackage

        private static void InstallLatestNugetPackage(IProject project, IVsPackageInstallerServices vsPackageInstallerServices, IVsPackageInstaller vsPackageInstaller, string packageId, int? majorVersion)
        {
            // lookup latest version for the given major (or null), and install that
            var latestVersion = GetLatestVersionForMajor(packageId, majorVersion);

            vsPackageInstaller.InstallPackage(
                ServiceMatrixOverrides.GetNugetFeedServiceBaseAddress() ?? "All",
                project.As<EnvDTE.Project>(),
                packageId,
                latestVersion,
                false);

            // Call the installed packages to get the version that was just installed and cache the version.
            // Packages are needed in case latestVersion is null,
            var installedPackages = vsPackageInstallerServices.GetInstalledPackages();
            NugetPackageVersionManager.UpdateCache(packageId, majorVersion, installedPackages);
        }
开发者ID:slamj1,项目名称:ServiceMatrix,代码行数:17,代码来源:SolutionExtensions.cs

示例4: InstallNugetPackageForSpecifiedVersion

 private static void InstallNugetPackageForSpecifiedVersion(IProject project, IVsPackageInstaller vsPackageInstaller, string packageName, string version)
 {
     vsPackageInstaller.InstallPackage("All",
          project.As<EnvDTE.Project>(),
          packageName,
          version,
          false);
 }
开发者ID:nulltoken,项目名称:ServiceMatrix,代码行数:8,代码来源:SolutionExtensions.cs

示例5: InstallLatestNugetPackage

        private static void InstallLatestNugetPackage(IProject project,IVsPackageInstallerServices vsPackageInstallerServices, IVsPackageInstaller vsPackageInstaller, string packageName)
        {
            vsPackageInstaller.InstallPackage("All",
                 project.As<EnvDTE.Project>(),
                 packageName,
                 (Version)null,
                 false);

            // Call the installed packages to get the version that was just installed and cache the version.
            var installedPackages = vsPackageInstallerServices.GetInstalledPackages();
            NugetPackageVersionManager.UpdateCache(packageName, installedPackages);
        }
开发者ID:nulltoken,项目名称:ServiceMatrix,代码行数:12,代码来源:SolutionExtensions.cs

示例6: RemoveLinkFromProject

        private void RemoveLinkFromProject(IProject project, string fileName, string suggestedPath)
        {
            var container = project.As<EnvDTE.Project>().ProjectItems;
            container = FindProjectFolder(container, suggestedPath);

            if (container != null)
            {
                foreach (var file in container)
                {
                    if (file != null && file.As<EnvDTE.ProjectItem>().Name == fileName)
                    {
                        file.As<ProjectItem>().Delete();
                        break;
                    }
                }
            }
        }
开发者ID:nanohex,项目名称:ServiceMatrix,代码行数:17,代码来源:Component.cs

示例7: AddLinkToProject

        private static void AddLinkToProject(IProject project, IProductElement element, string suggestedPath, Func<IEnumerable<IItem>, IItem> filter)
        {
            var sourceFile = FindSourceItemForElement(element, filter);
            var container = project.As<EnvDTE.Project>().ProjectItems;
            container = FindProjectFolder(container, suggestedPath);

            if (container != null)
            {
                try
                {
                    container.AddFromFile(sourceFile.PhysicalPath);
                }
                catch { } // If the link is already in place we will ignore the exception
            }
        }
开发者ID:nanohex,项目名称:ServiceMatrix,代码行数:15,代码来源:Component.cs


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