本文整理汇总了C#中IEnvironment.GetEnvironmentVariable方法的典型用法代码示例。如果您正苦于以下问题:C# IEnvironment.GetEnvironmentVariable方法的具体用法?C# IEnvironment.GetEnvironmentVariable怎么用?C# IEnvironment.GetEnvironmentVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnvironment
的用法示例。
在下文中一共展示了IEnvironment.GetEnvironmentVariable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppVeyor
public AppVeyor(Logger logger, IEnvironment environment, IHttpClientFactory httpClientFactory)
{
_logger = logger;
_environment = environment;
_httpClientFactory = httpClientFactory;
_appVeyorApiUrl = _environment.GetEnvironmentVariable("APPVEYOR_API_URL");
}
示例2: Resolve
internal static string Resolve(IEnvironment envirnment, IFileSystem fileSystem, IRuntimeEnvironment runtimeEnvironment)
{
var path = envirnment.GetEnvironmentVariable(DotNetReferenceAssembliesPathEnv);
if (!string.IsNullOrEmpty(path))
{
return path;
}
return GetDefaultDotNetReferenceAssembliesPath(fileSystem, runtimeEnvironment);
}
示例3: GetDefaultPackageDirectory
internal static string GetDefaultPackageDirectory(IRuntimeEnvironment runtimeEnvironment, IEnvironment environment)
{
var packageDirectory = environment.GetEnvironmentVariable("NUGET_PACKAGES");
if (!string.IsNullOrEmpty(packageDirectory))
{
return packageDirectory;
}
string basePath;
if (runtimeEnvironment.OperatingSystemPlatform == Platform.Windows)
{
basePath = environment.GetEnvironmentVariable("USERPROFILE");
}
else
{
basePath = environment.GetEnvironmentVariable("HOME");
}
if (string.IsNullOrEmpty(basePath))
{
return null;
}
return Path.Combine(basePath, ".nuget", "packages");
}
示例4: GetFallbackSearchPaths
internal static string[] GetFallbackSearchPaths(IFileSystem fileSystem, IRuntimeEnvironment runtimeEnvironment, IEnvironment environment)
{
if (runtimeEnvironment.OperatingSystemPlatform != Platform.Windows)
{
return new string[0];
}
var net20Dir = Path.Combine(environment.GetEnvironmentVariable("WINDIR"), "Microsoft.NET", "Framework", "v2.0.50727");
if (!fileSystem.Directory.Exists(net20Dir))
{
return new string[0];
}
return new[] { net20Dir };
}
示例5: GetDefaultReferenceAssembliesPath
internal static string GetDefaultReferenceAssembliesPath(IRuntimeEnvironment runtimeEnvironment, IEnvironment environment)
{
// Allow setting the reference assemblies path via an environment variable
var referenceAssembliesPath = environment.GetEnvironmentVariable("DOTNET_REFERENCE_ASSEMBLIES_PATH");
if (!string.IsNullOrEmpty(referenceAssembliesPath))
{
return referenceAssembliesPath;
}
if (runtimeEnvironment.OperatingSystemPlatform != Platform.Windows)
{
// There is no reference assemblies path outside of windows
// The environment variable can be used to specify one
return null;
}
// References assemblies are in %ProgramFiles(x86)% on
// 64 bit machines
var programFiles = environment.GetEnvironmentVariable("ProgramFiles(x86)");
if (string.IsNullOrEmpty(programFiles))
{
// On 32 bit machines they are in %ProgramFiles%
programFiles = environment.GetEnvironmentVariable("ProgramFiles");
}
if (string.IsNullOrEmpty(programFiles))
{
// Reference assemblies aren't installed
return null;
}
return Path.Combine(
programFiles,
"Reference Assemblies", "Microsoft", "Framework");
}
示例6: GetDefaultReferenceAssembliesPath
internal static string GetDefaultReferenceAssembliesPath(IFileSystem fileSystem, Platform platform, IEnvironment environment)
{
// Allow setting the reference assemblies path via an environment variable
var referenceAssembliesPath = DotNetReferenceAssembliesPathResolver.Resolve(environment, fileSystem);
if (!string.IsNullOrEmpty(referenceAssembliesPath))
{
return referenceAssembliesPath;
}
if (platform != Platform.Windows)
{
// There is no reference assemblies path outside of windows
// The environment variable can be used to specify one
return null;
}
// References assemblies are in %ProgramFiles(x86)% on
// 64 bit machines
var programFiles = environment.GetEnvironmentVariable("ProgramFiles(x86)");
if (string.IsNullOrEmpty(programFiles))
{
// On 32 bit machines they are in %ProgramFiles%
programFiles = environment.GetEnvironmentVariable("ProgramFiles");
}
if (string.IsNullOrEmpty(programFiles))
{
// Reference assemblies aren't installed
return null;
}
return Path.Combine(
programFiles,
"Reference Assemblies", "Microsoft", "Framework");
}
示例7: GetDefaultPackageCacheDirectory
internal static string GetDefaultPackageCacheDirectory(IEnvironment environment)
{
return environment.GetEnvironmentVariable("DOTNET_PACKAGES_CACHE");
}