Exemple #1
0
        /// <summary>
        /// The main entry point of the program.
        /// </summary>
        /// <returns>A task.</returns>
        public static async Task Main()
        {
            // Connect to uncaught exceptions for logging
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            // Configure logging
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            log4net.Config.XmlConfigurator.Configure(logRepository, new FileInfo("app.config"));

            // Log.Debug($"Starting up. Running on {RuntimeInformation.OSDescription}");

            // Initialize
            var contentService = new ContentService();

            try
            {
                await contentService.InitializeAsync();
            }
            catch (FileNotFoundException fex)
            {
                Log.Error("Could not initialize content service.", fex);
                return;
            }

            var ambassadorClient = new AmbassadorClient(contentService);
            await ambassadorClient.LoginAsync();

            await ambassadorClient.StartAsync();

            // Wait for shutdown
            await Task.Delay(-1);
        }
        /// <summary>
        /// The main entry point of the program.
        /// </summary>
        /// <returns>A task.</returns>
        public static async Task Main()
        {
            // Connect to uncaught exceptions for logging
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            // Configure logging
            const string configurationName = "DIGOS.Ambassador.log4net.config";
            var          logConfig         = new XmlDocument();

            using (var configStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(configurationName))
            {
                logConfig.Load(configStream);
            }

            var repo = LogManager.CreateRepository(Assembly.GetEntryAssembly(), typeof(Hierarchy));

            XmlConfigurator.Configure(repo, logConfig["log4net"]);

            Log.Debug($"Running on {RuntimeInformation.FrameworkDescription}");

            // Initialize
            var ambassadorClient = new AmbassadorClient();
            await ambassadorClient.InitializeAsync();

            var loginResult = await ambassadorClient.LoginAsync();

            if (!loginResult.IsSuccess)
            {
                Log.Error(loginResult.ErrorReason);
                return;
            }

            await ambassadorClient.StartAsync();

            // Wait for shutdown
            await Task.Delay(-1);
        }