Exemple #1
0
        private static LibraryOptions LoadLibraryOptions(string path)
        {
            try
            {
                var result = XmlSerializer.DeserializeFromFile(typeof(LibraryOptions), GetLibraryOptionsPath(path)) as LibraryOptions;
                if (result == null)
                {
                    return(new LibraryOptions());
                }

                foreach (var mediaPath in result.PathInfos)
                {
                    if (!string.IsNullOrEmpty(mediaPath.Path))
                    {
                        mediaPath.Path = ApplicationHost.ExpandVirtualPath(mediaPath.Path);
                    }
                }

                return(result);
            }
            catch (FileNotFoundException)
            {
                return(new LibraryOptions());
            }
            catch (IOException)
            {
                return(new LibraryOptions());
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "Error loading library options");

                return(new LibraryOptions());
            }
        }