aboutsummaryrefslogtreecommitdiff
path: root/Source/AddIn/RegistryUtil.cs
blob: 6ab7682f61252522e56534d5fb3342abf2db6dd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Microsoft.Win32;

namespace RehauSku
{
    static class RegistryUtil
    {
        public static string PriceListPath
        {
            get => (string)_RootKey.GetValue("PriceListPath");
        }

        public static ResponseOrder StoreResponseOrder
        {
            get => (ResponseOrder)_RootKey.GetValue("StoreResponseOrder");
        }

        private static RegistryKey _RootKey
        {
            get
            {
                return _OpenRootKey() ?? _CreateRootKey();
            }
        }

        private static RegistryKey _OpenRootKey()
        {
            return Registry.CurrentUser
                .OpenSubKey(@"SOFTWARE\REHAU\SkuAssist");
        }

        private static RegistryKey _CreateRootKey()
        {
            RegistryKey key = Registry.CurrentUser
                .CreateSubKey(@"SOFTWARE\REHAU\SkuAssist");

            key.SetValue("PriceListPath", @"D:\Dropbox\Рабочее\Таблица заказов ИС EAE_2021.xlsm");
            key.SetValue("StoreResponseOrder", 0);

            return key;
        }
    }
}