<commit_before>﻿using System;
using System.IO;
using Anotar.NLog;
using Ninject;
using Ninject.Extensions.Factory;
using SOVND.Client.Modules;
using SOVND.Client.Settings;
using SOVND.Client.Util;
using SOVND.Lib.Handlers;
using SOVND.Lib.Models;
using SOVND.Lib.Settings;

namespace SOVND.Client
{
    internal static class Program
    {
        [STAThread]
        public static void Main()
        {
            LogTo.Trace("Starting client (version TODO)");

            IKernel kernel = new StandardKernel();
            kernel.Bind<IMQTTSettings>().To<SovndMqttSettings>();
            kernel.Bind<IPlaylistProvider>().To<ObservablePlaylistProvider>();
            kernel.Bind<ISettingsProvider>().To<FilesystemSettingsProvider>();
            kernel.Bind<IFileLocationProvider>().To<AppDataLocationProvider>();
            kernel.Bind<IAppName>().To<AppName>();

            // Singleton classes
            kernel.Bind<ChannelDirectory>().ToSelf().InSingletonScope();
            kernel.Bind<SovndClient>().ToSelf().InSingletonScope();

            // Factories
            kernel.Bind<IChannelHandlerFactory>().ToFactory();
            kernel.Bind<IChatProviderFactory>().ToFactory();
            kernel.Bind<IPlayerFactory>().ToFactory();

            LogTo.Trace("All libraries bound, checking settings");

            // Instantiating this class checks settings and shows UI if they're not set
            kernel.Get<CheckSettings>();

            LogTo.Trace("Settings checked, starting libspotify");

            // Instantiating this initializes Spotify
            kernel.Get<StartSpotify>();

            LogTo.Trace("Instantiating main window");
            var window = kernel.Get<MainWindow>();

            LogTo.Trace("Running");
            var app = kernel.Get<App>();
            app.Run(window);
        }

    }
}<commit_msg>Only allow one instance of SOVND to run at a time<commit_after>﻿using System;
using System.IO;
using System.Threading;
using System.Windows;
using Anotar.NLog;
using Ninject;
using Ninject.Extensions.Factory;
using SOVND.Client.Modules;
using SOVND.Client.Settings;
using SOVND.Client.Util;
using SOVND.Lib.Handlers;
using SOVND.Lib.Models;
using SOVND.Lib.Settings;

namespace SOVND.Client
{
    internal static class Program
    {
        [STAThread]
        public static void Main()
        {
            if (AlreadyRunning())
                return;

            IKernel kernel = new StandardKernel();
            kernel.Bind<IMQTTSettings>().To<SovndMqttSettings>();
            kernel.Bind<IPlaylistProvider>().To<ObservablePlaylistProvider>();
            kernel.Bind<ISettingsProvider>().To<FilesystemSettingsProvider>();
            kernel.Bind<IFileLocationProvider>().To<AppDataLocationProvider>();
            kernel.Bind<IAppName>().To<AppName>();

            // Singleton classes
            kernel.Bind<ChannelDirectory>().ToSelf().InSingletonScope();
            kernel.Bind<SovndClient>().ToSelf().InSingletonScope();

            // Factories
            kernel.Bind<IChannelHandlerFactory>().ToFactory();
            kernel.Bind<IChatProviderFactory>().ToFactory();
            kernel.Bind<IPlayerFactory>().ToFactory();

            LogTo.Trace("All libraries bound, checking settings");

            // Instantiating this class checks settings and shows UI if they're not set
            kernel.Get<CheckSettings>();

            LogTo.Trace("Settings checked, starting libspotify");

            // Instantiating this initializes Spotify
            kernel.Get<StartSpotify>();

            LogTo.Trace("Instantiating main window");
            var window = kernel.Get<MainWindow>();

            LogTo.Trace("Running");
            var app = kernel.Get<App>();
            app.Run(window);
        }

        private static bool AlreadyRunning()
        {
            bool exclusive;
            using (Mutex m = new Mutex(true, "b1cddd64-d226-40ca-9a17-1221174b3e2c", out exclusive))
            {
                if (exclusive)
                {
                    return true;
                }
                MessageBox.Show("SOVND is already running.", "SOVND is already running", MessageBoxButton.OK, MessageBoxImage.Information);
                return false;
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.11480009352349778, 'fraction_numerical': 0.004676174888940846, 'mean_word_length': 2.3421875, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6114288', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1115, 'n_words': 227}