private static CrmImportConfig GetRootedConfiguration(CrmImportConfig config, string rootDirectory) { if (!string.IsNullOrEmpty(config.JsonFolderPath) && !Path.IsPathRooted(config.JsonFolderPath)) { config.JsonFolderPath = Path.Combine(rootDirectory, config.JsonFolderPath); } return(config); }
/// <summary> /// Reads settings from file. /// </summary> /// <param name="filePath">filePath.</param> /// <returns>return value.</returns> public static CrmImportConfig GetConfiguration(string filePath) { FileInfo configFile = new FileInfo(filePath); CrmImportConfig obj; if (configFile.Exists) { obj = GetRootedConfiguration( JsonConvert.DeserializeObject <CrmImportConfig>( File.ReadAllText(configFile.FullName), JsonSerializerConfig.SerializerSettings), configFile.DirectoryName); } else { obj = new CrmImportConfig(); } return(obj); }