/// <summary> /// Reads configuration from file. /// </summary> /// <param name="filePath">filePath.</param> /// <returns>value.</returns> public static CrmExporterConfig GetConfiguration(string filePath) { FileInfo configFile = new FileInfo(filePath); CrmExporterConfig obj; if (configFile.Exists) { obj = GetRootedConfiguration( JsonConvert.DeserializeObject <CrmExporterConfig>( File.ReadAllText(configFile.FullName), JsonSerializerConfig.SerializerSettings), configFile.DirectoryName); } else { obj = new CrmExporterConfig(); } return(obj); }
private static CrmExporterConfig GetRootedConfiguration(CrmExporterConfig config, string rootDirectory) { for (int i = 0; i < config.CrmMigrationToolSchemaPaths.Count; i++) { var path = config.CrmMigrationToolSchemaPaths[i]; if (!string.IsNullOrEmpty(path) && !Path.IsPathRooted(path)) { config.CrmMigrationToolSchemaPaths[i] = Path.Combine(rootDirectory, path); } } if (!string.IsNullOrEmpty(config.FetchXMLFolderPath) && !Path.IsPathRooted(config.FetchXMLFolderPath)) { config.FetchXMLFolderPath = Path.Combine(rootDirectory, config.FetchXMLFolderPath); } if (!string.IsNullOrEmpty(config.JsonFolderPath) && !Path.IsPathRooted(config.JsonFolderPath)) { config.JsonFolderPath = Path.Combine(rootDirectory, config.JsonFolderPath); } return(config); }