本文整理汇总了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.
}
}
示例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);
}
示例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);
}
示例4: InstallNugetPackageForSpecifiedVersion
private static void InstallNugetPackageForSpecifiedVersion(IProject project, IVsPackageInstaller vsPackageInstaller, string packageName, string version)
{
vsPackageInstaller.InstallPackage("All",
project.As<EnvDTE.Project>(),
packageName,
version,
false);
}
示例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);
}
示例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;
}
}
}
}
示例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
}
}