/// <summary>
        /// Loads the options from a TOML file in the directory specified in the <see cref="FilePath"/> property.
        /// If the <see cref="FilePath"/> property is null or empty will default to "/USER/Pellucid/pellucid.console-options[id].toml",
        /// where the "01" is the application number, padded to 2 places on a processor and the RoomId on a server.
        /// <para>If it exists, this file is automatically loaded when the application first starts.</para>
        /// </summary>
        /// <returns>An <see cref="Options"/> object.</returns>
        private static Options Load()
        {
            ValidateFilePath();

            if (File.Exists(FilePath))
            {
                try
                {
                    var options = MinimalTomlParser.DeserializeFromDisk <Options>(FilePath);
                    CrestronEnvironment.ProgramStatusEventHandler -= options.HandleAutoLoad;

                    if (options.AutoSave)
                    {
                        CrestronEnvironment.ProgramStatusEventHandler += options.HandleAutoLoad;
                    }

                    return(options);
                }
                catch (Exception ex)
                {
                    Logger.LogWarning("Options", "Exception while loading Evands.Pellucid options from disk. Using the defaults instead.\n{0}", ex.ToString());
                    return(new Options().WithDefaults());
                }
            }
            else
            {
                return(new Options().WithDefaults());
            }
        }
示例#2
0
        /// <summary>
        /// Loads the options from a TOML file in the application directory.
        /// <para>If it exists, this file is automatically loaded when the application first starts.</para>
        /// </summary>
        /// <returns>An <see cref="Options"/> object.</returns>
        private static Options Load()
        {
            var path = Path.Combine(InitialParametersClass.ProgramDirectory.ToString(), "pellucid.console-options.toml");

            if (File.Exists(path))
            {
                try
                {
                    var options = MinimalTomlParser.DeserializeFromDisk <Options>(path);
                    return(options);
                }
                catch (Exception ex)
                {
                    ConsoleBase.WriteLine("Exception while loading Evands.Pellucid options from disk. Using the defaults instead.\n{0}", ex.ToString());
                    return(new Options().WithDefaults());
                }
            }
            else
            {
                return(new Options().WithDefaults());
            }
        }
        /// <summary>
        /// Loads the options from a TOML file in the directory specified in the <see cref="FilePath"/> property.
        /// <para>If it exists, this file is automatically loaded when the application first starts.</para>
        /// </summary>
        /// <returns>An <see cref="Options"/> object.</returns>
        private static Options Load()
        {
#if !TEST
            if (File.Exists(FilePath))
            {
                try
                {
                    var options = MinimalTomlParser.DeserializeFromDisk <Options>(FilePath);
                    return(options);
                }
                catch (Exception ex)
                {
                    Logger.LogWarning("Options", "Exception while loading Evands.Pellucid options from disk. Using the defaults instead.\n{0}", ex.ToString());
                    return(new Options().WithDefaults());
                }
            }
            else
            {
                return(new Options().WithDefaults());
            }
#else
            return(new Options().WithDefaults());
#endif
        }