Пример #1
0
        /// <summary>Deserialize the theme from a file path.</summary>
        /// <param name="filePath">The file path.</param>
        /// <returns>The <see cref="Theme" />.</returns>
        public static Theme Deserialize(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new NoNullAllowedException(ArgumentMessages.IsNullOrEmpty());
            }

            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException(ArgumentMessages.FileNotFound(filePath));
            }

            Theme _theme = null;

            try
            {
                XDocument themeDocument = XDocument.Load(filePath);
                _theme = Deserialize(themeDocument);
            }
            catch (Exception e)
            {
                Logger.WriteDebug(e);
            }

            return(_theme);
        }
Пример #2
0
        /// <summary>Loads the <see cref="Theme" /> from the file path.</summary>
        /// <param name="filePath">The file path.</param>
        public void Load(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new NoNullAllowedException(ArgumentMessages.IsNullOrEmpty());
            }

            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException(ArgumentMessages.FileNotFound(filePath));
            }

            try
            {
                if (File.Exists(filePath))
                {
                    Theme theme = ThemeSerialization.Deserialize(filePath);
                    UpdateTheme(theme.Information, theme.ColorPalette);
                }
                else
                {
                    Logger.WriteDebug(new FileNotFoundException(ArgumentMessages.FileNotFound(filePath)));
                }
            }
            catch (Exception e)
            {
                Logger.WriteDebug(e);
            }
        }
Пример #3
0
        /// <summary>Loads the <see cref="Assembly" /> from a file.</summary>
        /// <param name="filePath">The file path.</param>
        /// <returns>The <see cref="Assembly" />.</returns>
        public static Assembly LoadAssembly(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                Logger.WriteDebug(new NoNullAllowedException(ArgumentMessages.IsNullOrEmpty()));
            }

            if (!File.Exists(filePath))
            {
                Logger.WriteDebug(new NoNullAllowedException(ArgumentMessages.FileNotFound(filePath)));
            }

            return(Assembly.LoadFile(filePath));
        }
Пример #4
0
        /// <summary>Initializes a new instance of the <see cref="Theme" /> class.</summary>
        /// <param name="filePath">The file.</param>
        public Theme(string filePath) : this()
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new NoNullAllowedException(ArgumentMessages.IsNullOrEmpty());
            }

            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException(ArgumentMessages.FileNotFound(filePath));
            }

            Load(filePath);
        }