private static IDataProtectionBuilder ConfigureForFile(IServiceCollection services, DataProtectionOptions dataProtectionOptions) { IDataProtectionBuilder builder = services.AddConfiguredDataProtection(); DataProtectionStorageOptions storageOptions = dataProtectionOptions.File; if (storageOptions == null) { throw new InvalidOperationException($"{nameof(DataProtectionOptions)}:{nameof(dataProtectionOptions.File)} not set"); } if (storageOptions.Path == "auto") { storageOptions.Path = EnvironmentPath.CreatePath("key-store"); } var directory = new DirectoryInfo(storageOptions.Path); directory.Create(); builder.PersistKeysToFileSystem( directory ); return(builder); }
private static void AddOperatingSpecificConfigurationFolders([NotNull] this IConfigurationBuilder cfg) { if (cfg == null) { throw new ArgumentNullException(nameof(cfg)); } const string configFileName = "config"; const string iniFileExt = "ini"; const string jsonFileExt = "json"; string MakeFilePath(string extension) { return(EmitConfigSearchMessage(EnvironmentPath.CreatePath(Path.ChangeExtension(configFileName, extension)))); } string EmitConfigSearchMessage(string path) { Console.WriteLine("\tLoading configuration from: {0}", path); return(path); } cfg.AddJsonFile(MakeFilePath(jsonFileExt), true); cfg.AddIniFile(MakeFilePath(iniFileExt), true); }
public void LoadSettings(DebuggingOptionsPage optionsPage) { defaultGdb.Text = String.Format(customGdbTextFormat, EnvironmentPath.FindExePath("gdb") ?? "<none>"); defaultGdb.Checked = !optionsPage.UseCustomGdbPath; customGdb.Checked = optionsPage.UseCustomGdbPath; customGdbPath.Text = optionsPage.DebuggerLocation; extraArgs.Text = optionsPage.ExtraArgs; }
/// <summary>Finds the location of file that match the search pattern. By default, the search is done along the current directory and in the paths specified by the PATH environment variable.</summary> /// <param name="filename">The filename to search for</param> /// <param name="throwIfNotFound">Throw <seealso cref="FileNotFoundException"/> if no result</param> /// <remarks>Too lazy, that's why this method is still here.</remarks> public static string Where(string filename, bool throwIfNotFound) { var paths = EnvironmentPath.Get(); paths.SafeSearchMode = false; if (throwIfNotFound) { return(paths.SearchForExact(filename, true)); } else { try { return(paths.SearchForExact(filename, true)); } catch (FileNotFoundException) { return(null); } } }
/// <summary>Finds the location of file that match the search pattern. By default, the search is done along the current directory and in the paths specified by the PATH environment variable.</summary> /// <param name="filename">The filename to search for</param> /// <exception cref="FileNotFoundException">The search yield no result</exception> /// <remarks>Too lazy, that's why this method is still here.</remarks> public static Task <string> WhereAsync(string filename) => Task.Run(() => { var paths = EnvironmentPath.Get(); paths.SafeSearchMode = false; return(paths.SearchForExact(filename)); });