public static bool SetConfiguration(string filePath, int retryParentDirectory = 2) { string path = FileEx.SearchParentDirectory(filePath, retryParentDirectory); if (path == null) { throw new FileNotFoundException(filePath); } NLog.LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration(path); return(true); }
public static T Load <T>(string filePath, int retryParentDirectory = 2) { var appDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string path = Path.Combine(appDirectory, filePath); path = FileEx.SearchParentDirectory(path, retryParentDirectory); if (path == null) { return(default(T)); } string json = File.ReadAllText(path); if (json == null) { throw new FileNotFoundException(filePath); } return(JsonConvert.DeserializeObject <T>(json)); }