-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
StorageFactory.cs
56 lines (47 loc) · 1.5 KB
/
StorageFactory.cs
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using UnityEngine;
namespace Bayat.SaveSystem.Storage
{
/// <summary>
/// The storage factory.
/// </summary>
public sealed class StorageFactory
{
/// <summary>
/// The singleton instance of factory.
/// </summary>
public static readonly StorageFactory Instance;
/// <summary>
/// The default storage implementation of this platform.
/// </summary>
public static IStorage DefaultStorage
{
get
{
if (string.IsNullOrEmpty(Application.persistentDataPath))
{
return FromConnectionString("playerprefs://");
}
else
{
return FromConnectionString("disk://path=" + Application.persistentDataPath);
}
}
}
static StorageFactory()
{
Instance = new StorageFactory();
}
private StorageFactory()
{
}
/// <summary>
/// Initializes a new instance of <see cref="IStorage"/> implementation by using the specified connection string.
/// </summary>
/// <param name="connectionString">The connection string</param>
/// <returns>A new instance of <see cref="IStorage"/> implementation</returns>
public static IStorage FromConnectionString(string connectionString)
{
return ConnectionStringFactory.CreateStorage(connectionString);
}
}
}