aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.BL/CacheManager.cs
blob: 389e178089e7e3875f9e38dc322044527440af12 (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
using LiteDB;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.FSE.BL
{
    public class CacheManager
    {
        public String DatabasePath { get; private set; }

        private static CacheManager _default;
        public static CacheManager Default
        {
            get
            {
                if (_default == null)
                {
                    _default = new CacheManager(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Cache", Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName) + ".cache"));
                }

                return _default;
            }
        }

        public CacheManager(String databasePath)
        {
            DatabasePath = databasePath;
        }

        public LiteDatabase CreateContext()
        {
            Directory.CreateDirectory(Path.GetDirectoryName(DatabasePath));
            return new LiteDatabase(DatabasePath);
        }
    }
}