generated from RageAgainstThePixel/upm-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
BlockadeLabsSettings.cs
73 lines (62 loc) · 2.67 KB
/
BlockadeLabsSettings.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Licensed under the MIT License. See LICENSE in the project root for license information.
using System.Linq;
using UnityEngine;
using Utilities.WebRequestRest.Interfaces;
namespace BlockadeLabs
{
public sealed class BlockadeLabsSettings : ISettings
{
/// <summary>
/// Creates a new instance of <see cref="BlockadeLabsSettings"/> with default <see cref="BlockadeLabsSettingsInfo"/>.
/// </summary>
public BlockadeLabsSettings()
{
Info = new BlockadeLabsSettingsInfo();
cachedDefault = this;
}
/// <summary>
/// Creates a new instance of <see cref="BlockadeLabsSettings"/> with provided <see cref="configuration"/>.
/// </summary>
/// <param name="configuration"><see cref="BlockadeLabsConfiguration"/>.</param>
public BlockadeLabsSettings(BlockadeLabsConfiguration configuration)
{
if (configuration == null)
{
Debug.LogWarning($"This can be speed up by directly passing a {nameof(BlockadeLabsConfiguration)} to the {nameof(BlockadeLabsSettings)}.ctr");
configuration = Resources.LoadAll<BlockadeLabsConfiguration>(string.Empty).FirstOrDefault(asset => asset != null);
}
if (configuration == null)
{
throw new MissingReferenceException($"Failed to find a valid {nameof(BlockadeLabsConfiguration)}!");
}
Info = new BlockadeLabsSettingsInfo(configuration.ProxyDomain);
cachedDefault = this;
}
/// <summary>
/// Creates a new instance of <see cref="BlockadeLabsSettings"/> with the provided <see cref="settingsInfo"/>.
/// </summary>
/// <param name="settingsInfo"><see cref="BlockadeLabsSettingsInfo"/>.</param>
public BlockadeLabsSettings(BlockadeLabsSettingsInfo settingsInfo)
{
Info = settingsInfo;
cachedDefault = this;
}
/// <summary>
/// Creates a new instance of <see cref="BlockadeLabsSettings"/>.
/// </summary>
/// <param name="domain">Base api domain.</param>
public BlockadeLabsSettings(string domain)
{
Info = new BlockadeLabsSettingsInfo(domain);
cachedDefault = this;
}
private static BlockadeLabsSettings cachedDefault;
public static BlockadeLabsSettings Default
{
get => cachedDefault ??= new BlockadeLabsSettings(configuration: null);
internal set => cachedDefault = value;
}
public BlockadeLabsSettingsInfo Info { get; }
public string BaseRequestUrlFormat => Info.BaseRequestUrlFormat;
}
}