<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Quandl.Shared
{
    public class QuandlConfig
    {
        public static string ApiKey
        {
            get { return Properties.Settings.Default.ApiKey; }
            set
            {
                Properties.Settings.Default.ApiKey = value;
                Properties.Settings.Default.Save();
            }
        }

        public static bool AutoUpdate
        {
            get { return Properties.Settings.Default.AutoUpdate; }
            set
            {
                Properties.Settings.Default.AutoUpdate = value;
                Properties.Settings.Default.Save();
            }
        }

        public static void Reset()
        {
            Properties.Settings.Default.Reset();
        }
    }
}<commit_msg>use registry<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Win32;

namespace Quandl.Shared
{
    public class QuandlConfig
    {
        private const string RegistrySubKey = @"SOFTWARE\Quandl\ExcelAddin";

        public static string ApiKey
        {
            get { return GetRegistry<string>("ApiKey"); }
            set { SetRegistryKeyValue("ApiKey", value); }
        }

        public static bool AutoUpdate
        {
            get { return Convert.ToBoolean(GetRegistry<int>("AutoUpdate")); }
            set { SetRegistryKeyValue("AutoUpdate", Convert.ToInt32(value), RegistryValueKind.DWord); }
        }

        public static void Reset()
        {
            Registry.CurrentUser.DeleteSubKeyTree(RegistrySubKey);
        }

        private static void SetRegistryKeyValue(string key, object value, RegistryValueKind regValueKing = RegistryValueKind.String)
        {
            var appKeyPath = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(RegistrySubKey);
            var apiSubKey = appKeyPath.CreateSubKey(key);
            apiSubKey.SetValue(key, value, regValueKing);
            apiSubKey.Close();
        }

        private static T GetRegistry<T>(string key)
        {
            var quandlRootKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(RegistrySubKey);
            if (quandlRootKey != null)
            {
                var subKey = quandlRootKey.OpenSubKey(key);
                if (subKey != null)
                {
                    return (T)subKey.GetValue(key, default(T));
                }
            }

            return default(T);
        }
    }
}
{'fraction_non_alphanumeric': 0.08873456790123457, 'fraction_numerical': 0.0030864197530864196, 'mean_word_length': 1.8779134295227524, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '5496973', 'n_tokens_mistral': 686, 'n_tokens_neox': 664, 'n_words': 133}