本文整理汇总了C#中IFileSystem.combine_paths方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.combine_paths方法的具体用法?C# IFileSystem.combine_paths怎么用?C# IFileSystem.combine_paths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileSystem
的用法示例。
在下文中一共展示了IFileSystem.combine_paths方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: set_config_items
private static void set_config_items(ChocolateyConfiguration config, ConfigFileSettings configFileSettings, IFileSystem fileSystem)
{
var cacheLocation = set_config_item(ApplicationParameters.ConfigSettings.CacheLocation, configFileSettings, string.IsNullOrWhiteSpace(configFileSettings.CacheLocation) ? string.Empty : configFileSettings.CacheLocation, "Cache location if not TEMP folder.");
config.CacheLocation = !string.IsNullOrWhiteSpace(cacheLocation) ? cacheLocation : fileSystem.combine_paths(fileSystem.get_temp_path(), "chocolatey"); // System.Environment.GetEnvironmentVariable("TEMP");
if (string.IsNullOrWhiteSpace(config.CacheLocation))
{
config.CacheLocation = fileSystem.combine_paths(ApplicationParameters.InstallLocation, "temp");
}
var originalCommandTimeout = configFileSettings.CommandExecutionTimeoutSeconds;
var commandExecutionTimeoutSeconds = -1;
int.TryParse(
set_config_item(
ApplicationParameters.ConfigSettings.CommandExecutionTimeoutSeconds,
configFileSettings,
originalCommandTimeout == 0 ?
ApplicationParameters.DefaultWaitForExitInSeconds.to_string()
: originalCommandTimeout.to_string(),
"Default timeout for command execution."),
out commandExecutionTimeoutSeconds);
config.CommandExecutionTimeoutSeconds = commandExecutionTimeoutSeconds;
if (configFileSettings.CommandExecutionTimeoutSeconds <= 0)
{
set_config_item(ApplicationParameters.ConfigSettings.CommandExecutionTimeoutSeconds, configFileSettings, ApplicationParameters.DefaultWaitForExitInSeconds.to_string(), "Default timeout for command execution.", forceSettingValue: true);
config.CommandExecutionTimeoutSeconds = ApplicationParameters.DefaultWaitForExitInSeconds;
}
config.ContainsLegacyPackageInstalls = set_config_item(ApplicationParameters.ConfigSettings.ContainsLegacyPackageInstalls, configFileSettings, "true", "Install has packages installed prior to 0.9.9 series.").is_equal_to(bool.TrueString);
config.Proxy.Location = set_config_item(ApplicationParameters.ConfigSettings.Proxy, configFileSettings, string.Empty, "Explicit proxy location.");
config.Proxy.User = set_config_item(ApplicationParameters.ConfigSettings.ProxyUser, configFileSettings, string.Empty, "Optional proxy user.");
config.Proxy.EncryptedPassword = set_config_item(ApplicationParameters.ConfigSettings.ProxyPassword, configFileSettings, string.Empty, "Optional proxy password. Encrypted.");
int minPositives=0;
int.TryParse(set_config_item(ApplicationParameters.ConfigSettings.VirusCheckMinimumPositives, configFileSettings, "5", "Optional proxy password. Encrypted."), out minPositives);
config.VirusCheckMinimumPositives = minPositives == 0 ? 5 : minPositives;
}
示例2: remove_old_chocolatey_exe
private static void remove_old_chocolatey_exe(IFileSystem fileSystem)
{
try
{
fileSystem.delete_file(fileSystem.get_current_assembly_path() + ".old");
fileSystem.delete_file(fileSystem.combine_paths(AppDomain.CurrentDomain.BaseDirectory, "choco.exe.old"));
}
catch (Exception ex)
{
"chocolatey".Log().Warn("Attempting to delete choco.exe.old ran into an issue:{0} {1}".format_with(Environment.NewLine, ex.Message));
}
}
示例3: extract_all_resources_to_relative_directory
public static void extract_all_resources_to_relative_directory(IFileSystem fileSystem, IAssembly assembly, string directoryPath, IList<string> relativeDirectories, string resourcesToInclude, bool overwriteExisting = false, bool logOutput = false)
{
var resourceString = new StringBuilder();
foreach (var resourceName in assembly.GetManifestResourceNames())
{
if (!resourceName.StartsWith(resourcesToInclude))
{
continue;
}
resourceString.Clear();
resourceString.Append(resourceName);
//var fileExtensionLocation = resourceName.LastIndexOf('.');
//resourceString.Remove(fileExtensionLocation, resourceString.Length - fileExtensionLocation);
resourceString.Replace(resourcesToInclude + ".", "");
foreach (var directory in relativeDirectories)
{
resourceString.Replace("{0}".format_with(directory), "{0}{1}".format_with(directory, fileSystem.get_path_directory_separator_char()));
}
// replacing \. with \
resourceString.Replace("{0}.".format_with(fileSystem.get_path_directory_separator_char()), "{0}".format_with(fileSystem.get_path_directory_separator_char()));
var fileLocation = resourceString.ToString();
//var fileLocation = fileSystem.combine_paths("", resourceString.ToString().Split('.')) + resourceName.Substring(fileExtensionLocation);
var filePath = fileSystem.combine_paths(directoryPath, fileLocation);
if (logOutput) "chocolatey".Log().Debug("Unpacking {0} to '{1}'".format_with(fileLocation,filePath));
extract_binary_file_from_assembly(fileSystem, assembly, resourceName, filePath, overwriteExisting);
}
}
示例4: set_file_configuration
private static void set_file_configuration(ChocolateyConfiguration config, IFileSystem fileSystem, IXmlService xmlService, Action<string> notifyWarnLoggingAction)
{
var globalConfigPath = ApplicationParameters.GlobalConfigFileLocation;
AssemblyFileExtractor.extract_text_file_from_assembly(fileSystem, Assembly.GetExecutingAssembly(), ApplicationParameters.ChocolateyConfigFileResource, globalConfigPath);
var configFileSettings = xmlService.deserialize<ConfigFileSettings>(globalConfigPath);
var sources = new StringBuilder();
foreach (var source in configFileSettings.Sources.Where(s => !s.Disabled).or_empty_list_if_null())
{
sources.AppendFormat("{0};", source.Value);
}
if (sources.Length != 0)
{
config.Sources = sources.Remove(sources.Length - 1, 1).ToString();
}
set_machine_sources(config, configFileSettings);
config.CacheLocation = !string.IsNullOrWhiteSpace(configFileSettings.CacheLocation) ? configFileSettings.CacheLocation : System.Environment.GetEnvironmentVariable("TEMP");
if (string.IsNullOrWhiteSpace(config.CacheLocation))
{
config.CacheLocation = fileSystem.combine_paths(ApplicationParameters.InstallLocation, "temp");
}
FaultTolerance.try_catch_with_logging_exception(
() => fileSystem.create_directory_if_not_exists(config.CacheLocation),
"Could not create temp directory at '{0}'".format_with(config.CacheLocation),
logWarningInsteadOfError: true);
config.ContainsLegacyPackageInstalls = configFileSettings.ContainsLegacyPackageInstalls;
if (configFileSettings.CommandExecutionTimeoutSeconds <= 0)
{
configFileSettings.CommandExecutionTimeoutSeconds = ApplicationParameters.DefaultWaitForExitInSeconds;
}
config.CommandExecutionTimeoutSeconds = configFileSettings.CommandExecutionTimeoutSeconds;
set_feature_flags(config, configFileSettings);
// save so all updated configuration items get set to existing config
FaultTolerance.try_catch_with_logging_exception(
() => xmlService.serialize(configFileSettings, globalConfigPath),
"Error updating '{0}'. Please ensure you have permissions to do so".format_with(globalConfigPath),
logWarningInsteadOfError: true);
}