public Models.Metadata Load(string filename) { using (var logger = _logger.Block()) { // get the name of the metadata file logger.Trace($"Getting metadata filename for image \"{filename}\"..."); var metadataFilename = GetMetadataFilename(filename); logger.Trace($"Loading from file \"{metadataFilename}\"..."); var metadata = _xmlFileSerialiser.Deserialise <Models.Metadata>(metadataFilename); // return the metadata return(metadata); } }
public void Load(CancellationToken cancellationToken) { using (var logger = _logger.Block()) { try { if (cancellationToken.IsCancellationRequested) { return; } Clear(); if (cancellationToken.IsCancellationRequested) { return; } logger.Trace("Getting path to recently used directories file..."); var filename = GetFilename(); if (cancellationToken.IsCancellationRequested) { return; } logger.Trace($@"Loading recently used directories from ""{filename}""..."); _recentlyUsedDirectories.AddRange(_xmlFileSerialiser.Deserialise <List <Folder> >(filename) ?? new List <Folder>()); foreach (var observer in _observers) { if (cancellationToken.IsCancellationRequested) { return; } SendRecentlyUsedDirectories(observer); } } catch (Exception ex) { logger.Trace($"Notifying {_observers.Count} observers of error..."); foreach (var observer in _observers) { observer.OnError(ex); } } } }