public void SetPathStrings(Hive hive, IEnumerable <string> strings) { string value = string.Join(";", strings); EnvironmentKey access = Access(hive); using (var environment = access(writable: true)) { if (environment == null) { throw new Error("Failed to open registry key"); } environment.SetValue(Path, value); NotifySettingsChange(); } }
public IEnumerable <string> GetPathStrings(Hive hive) { EnvironmentKey access = Access(hive); using (var environment = access(writable: false)) { if (environment == null) { throw new Error("Failed to open registry key"); } object values = environment.GetValue(Path) ?? "No PATH variable"; IEnumerable <string> result = values.ToString().Split(';'); return(result); } }
public static T GetConfigByKey <T>(this EnvironmentKey key, Func <T> getT, Dictionary <EnvironmentKey, dynamic> config = null) { if (config == null) { config = Config; } if (!config.ContainsKey(key)) { config.Add(key, getT()); } if (config[key] == null) { config[key] = getT(); } try { return(config[key]); } catch { } return(default(T)); }
public static string?Get(this EnvironmentKey key) { return(Environment.GetEnvironmentVariable(key.ToString())); }
public static string GetOrThrow(this EnvironmentKey key) { return(EnvironmentExtensions.GetOrThrow(key.ToString())); }
public static bool TryGet(this EnvironmentKey key, [NotNullWhen(true)] out string?value) { return(EnvironmentExtensions.TryGetEnvironmentVariable(key.ToString(), out value)); }