예제 #1
0
        internal static Settings FromFile(string filename)
        {
            if (String.IsNullOrEmpty(filename))
            {
                throw new ArgumentNullException(nameof(filename));
            }
            if (!Common.FileExists(filename))
            {
                throw new FileNotFoundException(nameof(filename));
            }

            string   contents = Common.ReadTextFile(@filename);
            Settings ret      = Common.DeserializeJson <Settings>(contents);

            return(ret);
        }
예제 #2
0
        /// <summary>
        /// Main method.
        /// </summary>
        /// <param name="args">Command line arguments.</param>
        public static void Main(string[] args)
        {
            _Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            bool initialSetup = false;

            if (args != null && args.Length >= 1)
            {
                if (String.Compare(args[0], "setup") == 0)
                {
                    initialSetup = true;
                }
            }

            if (!Common.FileExists("System.json"))
            {
                initialSetup = true;
            }
            if (initialSetup)
            {
                Setup setup = new Setup();
            }

            _Settings = Settings.FromFile("System.json");

            Welcome(initialSetup);
            CreateDirectories();
            InitializeGlobals();

            if (_Settings.EnableConsole && Environment.UserInteractive)
            {
                _ConsoleMgr.Worker();
            }
            else
            {
                EventWaitHandle waitHandle       = new EventWaitHandle(false, EventResetMode.AutoReset, null);
                bool            waitHandleSignal = false;
                do
                {
                    waitHandleSignal = waitHandle.WaitOne(1000);
                }while (!waitHandleSignal);
            }

            _Logging.Debug(_Header + "exiting");
        }