예제 #1
0
        /// <summary>
        /// Tries the load the job settings from the specified path.
        /// </summary>
        /// <param name="path">The path to the file with the serialized setzings.</param>
        /// <exception cref="CorruptSaveFileException">The save file is in an invalid state.</exception>
        /// <exception cref="ITunesNotOpenedException">The iTunes process is not started..</exception>
        /// <returns>
        /// The result of the operation.
        /// </returns>
        public static IEnumerable <JobSetting> LoadJobSettings(string path)
        {
            IEnumerable <JobSetting> settings;

            try
            {
                settings = GenericXmlSerializer.DeserializeCollection <JobSetting>(path);
            }

            catch (InvalidOperationException ex)
            {
                throw new CorruptSaveFileException("The save file is corrupt.", ex);
            }

            if (settings.Any(setting => setting.FirstFileSystemSetting is ITunesFileSystemSetting && !DataController.IsITunesOpened()))
            {
                throw new ITunesNotOpenedException("iTunes is not opened.");
            }

            return(settings);
        }