forked from Fydar/RPGCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPackageResourceDependency.cs
60 lines (51 loc) · 1.48 KB
/
PackageResourceDependency.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
using System.Collections.Generic;
using System.Diagnostics;
namespace RPGCore.Packages
{
/// <summary>
/// Represents a dependency on a <see cref="PackageResource"/>.
/// </summary>
public class PackageResourceDependency : IResourceDependency
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly PackageExplorer packageExplorer;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly Dictionary<string, string> metdadata;
/// <summary>
/// The resource referenced by this dependency.
/// </summary>
public IReadOnlyDictionary<string, string> Metadata => metdadata;
/// <summary>
/// Determines the validity of this dependency relationship.
/// </summary>
public bool IsValid => packageExplorer.Resources.Contains(Key);
/// <summary>
/// A key used to identify this dependency.
/// </summary>
public string Key { get; }
/// <summary>
/// The resource referenced by this dependency.
/// </summary>
public PackageResource? Resource
{
get
{
try
{
return packageExplorer.Resources[Key];
}
catch
{
return null;
}
}
}
[DebuggerBrowsable(DebuggerBrowsableState.Never)] IResource? IResourceDependency.Resource => Resource;
internal PackageResourceDependency(PackageExplorer packageExplorer, PackageResourceMetadataDependencyModel dependencyModel)
{
this.packageExplorer = packageExplorer;
Key = dependencyModel.Resource;
metdadata = new Dictionary<string, string>();
}
}
}