/// <summary> /// Attempts to construct and return a file-based properties provider /// </summary> /// <param name="defaultPropertiesFileDirectory">Directory in which to look for the default properties file (optional)</param> /// <param name="commandLineArguments">List of command line arguments (optional)</param> /// <returns>False if errors occurred when constructing the provider, otherwise true</returns> /// <remarks>If a properties file could not be located then an empty provider will be returned</remarks> public static bool TryCreateProvider(IEnumerable <ArgumentInstance> commandLineArguments, string defaultPropertiesFileDirectory, ILogger logger, out IAnalysisPropertyProvider provider) { if (commandLineArguments == null) { throw new ArgumentNullException("commandLineArguments"); } if (string.IsNullOrWhiteSpace(defaultPropertiesFileDirectory)) { throw new ArgumentNullException("defaultDirectory"); } if (logger == null) { throw new ArgumentNullException("logger"); } // If the path to a properties file was specified on the command line, use that. // Otherwise, look for a default properties file in the default directory. bool settingsFileArgExists = ArgumentInstance.TryGetArgumentValue(DescriptorId, commandLineArguments, out string propertiesFilePath); if (ResolveFilePath(propertiesFilePath, defaultPropertiesFileDirectory, logger, out AnalysisProperties locatedPropertiesFile)) { if (locatedPropertiesFile == null) { provider = EmptyPropertyProvider.Instance; } else { provider = new FilePropertyProvider(locatedPropertiesFile, !settingsFileArgExists); } return(true); } provider = null; return(false); }
public static FilePropertyProvider Load(string filePath) { if (string.IsNullOrWhiteSpace(filePath)) { throw new ArgumentNullException("filePath"); } if (!File.Exists(filePath)) { throw new FileNotFoundException(Resources.ERROR_SettingsFileNotFound, filePath); } AnalysisProperties properties = AnalysisProperties.Load(filePath); FilePropertyProvider provider = new FilePropertyProvider(properties, false); return(provider); }
/// <summary> /// Attempts to construct and return a file-based properties provider /// </summary> /// <param name="defaultPropertiesFileDirectory">Directory in which to look for the default properties file (optional)</param> /// <param name="commandLineArguments">List of command line arguments (optional)</param> /// <returns>False if errors occurred when constructing the provider, otherwise true</returns> /// <remarks>If a properties file could not be located then an empty provider will be returned</remarks> public static bool TryCreateProvider(IEnumerable<ArgumentInstance> commandLineArguments, string defaultPropertiesFileDirectory, ILogger logger, out IAnalysisPropertyProvider provider) { if (commandLineArguments == null) { throw new ArgumentNullException("commandLineArguments"); } if (string.IsNullOrWhiteSpace(defaultPropertiesFileDirectory)) { throw new ArgumentNullException("defaultDirectory"); } if (logger == null) { throw new ArgumentNullException("logger"); } // If the path to a properties file was specified on the command line, use that. // Otherwise, look for a default properties file in the default directory. string propertiesFilePath; bool settingsFileArgExists = ArgumentInstance.TryGetArgumentValue(DescriptorId, commandLineArguments, out propertiesFilePath); AnalysisProperties locatedPropertiesFile; if (ResolveFilePath(propertiesFilePath, defaultPropertiesFileDirectory, logger, out locatedPropertiesFile)) { if (locatedPropertiesFile == null) { provider = EmptyPropertyProvider.Instance; } else { provider = new FilePropertyProvider(locatedPropertiesFile, !settingsFileArgExists); } return true; } provider = null; return false; }
public static FilePropertyProvider Load(string filePath) { if (string.IsNullOrWhiteSpace(filePath)) { throw new ArgumentNullException("filePath"); } if (!File.Exists(filePath)) { throw new FileNotFoundException(Resources.ERROR_SettingsFileNotFound, filePath); } AnalysisProperties properties = AnalysisProperties.Load(filePath); FilePropertyProvider provider = new FilePropertyProvider(properties, false); return provider; }