public bool AddXpForLanguage(string lang, int xp)
        {
            Logger.Debug($"Adding {xp} XP for {lang}");
            if (!CodeStatsSettingsProvider.GetSingleton().TrackPlainText&& lang.Equals("Plain text"))
            {
                Logger.Debug("plain text-ignore");
                return(false);
            }
            bool foundExisting = false;

            foreach (XpObj xpobj in xps)
            {
                if (xpobj.language == lang)
                {
                    foundExisting = true;
                    xpobj.AddXp(xp);
                }
            }

            if (!foundExisting)
            {
                xps.Add(new XpObj(lang, xp));
            }

            coded_at = DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ssK");
            return(true);
        }
 public static CodeStatsSettingsProvider GetSingleton()
 {
     if (cssp == null)
     {
         cssp = new CodeStatsSettingsProvider();
     }
     return(cssp);
 }
 public void AddXp(int count)
 {
     xp += count;
     if (!CodeStatsSettingsProvider.GetSingleton().TrackPlainText&& language.Equals("Plain text"))
     {
         xp = 0;
     }
 }
 public XpObj(string lang, int initialXp)
 {
     language = lang;
     xp       = initialXp;
     if (!CodeStatsSettingsProvider.GetSingleton().TrackPlainText&& language.Equals("Plain text"))
     {
         xp = 0;
     }
 }
        internal static void Debug(object message, bool DoNotLogExtendedDebug = false,
                                   [System.Runtime.CompilerServices.CallerMemberName] string function = "",
                                   [System.Runtime.CompilerServices.CallerFilePath] string file       = "",
                                   [System.Runtime.CompilerServices.CallerLineNumber] int line        = 0)
        {
            if (DoNotLogExtendedDebug || !CodeStatsSettingsProvider.GetSingleton().EnableDebugLogging)
            {
                return;
            }
            String mssg = "[Code::Stats Debug at " + DateTime.Now.ToString("HH:mm:ss") + " in " + file.Substring(file.LastIndexOf(System.IO.Path.DirectorySeparatorChar) + 1) + ":" + line + " | " + function + "()]: " + message;

            LogLine(mssg);
        }
        private static void InitializeAsync()
        {
            if (System.Net.ServicePointManager.SecurityProtocol != 0)
            {
                // If the value is not set to 0 (SystemDefault), disable old protocols and make sure TLS 1.3, 1.2, 1.1 are enabled
                System.Net.ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Ssl3;
                System.Net.ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Tls;
                System.Net.ServicePointManager.SecurityProtocol |= (SecurityProtocolType)12288 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;
            }

            try
            {
                // Delete existing log file to save space
                Logger.Delete();
            }
            catch { }

            Logger.Info($"Initializing Code::Stats v{Constants.PluginVersion}");

            try
            {
                currentPulse = new Pulse();
                Logger.Info("Initialing settings form...");
                // Settings Form
                _settingsForm = new CodeStats.Forms.SettingsForm();
                _settingsForm.OnSettingsSaved += SettingsFormOnConfigSaved;
                Logger.Info("Initialized settings form");                 // it takes 5 seconds to get here from Initializing Code::Stats message...

                // Load config file
                codeStatsSettings = CodeStatsSettingsProvider.GetSingleton();
                GetSettings(true);

                Logger.Debug("Loaded config");

                LoadExtensionMapping();


                if (String.IsNullOrEmpty(codeStatsSettings.ApiKey))
                {
                    PromptApiKey();                     // Prompt for API token if not already set
                }

                // setup timer to process queued pulses
                pulseProcessor_tokensource       = new CancellationTokenSource();
                pulseProcessor_httpClientHandler = new HttpClientHandler
                {
                    Proxy = GetProxy()
                };
                proxyChangePending    = false;
                pulseProcessor_client = new HttpClient(pulseProcessor_httpClientHandler);
                timer.Interval        = pulseFrequency;
                timer.Elapsed        += ProcessPulses;
                timer.Start();


                Logger.Info($"Finished initializing Code::Stats v{Constants.PluginVersion}");
            }
            catch (Exception ex)
            {
                Logger.Error("Error Initializing Code::Stats", ex);
            }
        }