private void ValidateConfigFile()
 {
     if (!DataStore.FileExists(ConfigPath) ||
         !JsonConfigHelper.ValidateConfigFileContent(DataStore.ReadFileAsText(ConfigPath), out _))
     {
         Debug.Write($"[ConfigInitializer] Failed to parse the config file at {ConfigPath}. Clearing the file.");
         ResetConfigFileToDefault();
     }
 }
Beispiel #2
0
 /// <summary>
 /// Creates an instance of <see cref="ConfigManager"/>.
 /// </summary>
 /// <param name="configFilePath">Path to the config file.</param>
 /// <param name="dataStore">Provider of file system APIs.</param>
 /// <param name="environmentVariableProvider">Provider of environment variable APIs.</param>
 internal ConfigManager(string configFilePath, IDataStore dataStore, IEnvironmentVariableProvider environmentVariableProvider)
 {
     _ = dataStore ?? throw new AzPSArgumentNullException($"{nameof(dataStore)} cannot be null.", nameof(dataStore));
     _ = configFilePath ?? throw new AzPSArgumentNullException($"{nameof(configFilePath)} cannot be null.", nameof(configFilePath));
     _ = environmentVariableProvider ?? throw new AzPSArgumentNullException($"{nameof(environmentVariableProvider)} cannot be null.", nameof(environmentVariableProvider));
     ConfigFilePath = configFilePath;
     _environmentVariableProvider = environmentVariableProvider;
     _dataStore        = dataStore;
     _jsonConfigHelper = new JsonConfigHelper(ConfigFilePath, _dataStore);
 }