This repository has been archived by the owner on Jul 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RenderParams.cs
67 lines (60 loc) · 2.24 KB
/
RenderParams.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
using System.Collections;
using System.Collections.Generic;
using Red.Interfaces;
namespace Red.EcsRenderer
{
/// <inheritdoc />
/// <summary>
/// Container for render parameters
/// </summary>
public sealed class RenderParams : IEnumerable<KeyValuePair<string, string>>
{
private readonly IDictionary<string, string> _dict = new Dictionary<string, string>();
/// <summary>
/// Attempts to retrieve the replacement data associated with the tag
/// Returns empty string if tag not found in parameters
/// </summary>
/// <param name="parName">The name of the tag to find replacement data for</param>
/// <returns>Replacement data for the given tag</returns>
public string this[string parName]
{
get
{
var res = "";
_dict.TryGetValue(parName, out res);
return res;
}
}
internal static IJsonConverter Converter { private get; set; }
/// <summary>
/// Adds tag and replacement-data pair to parameters
/// </summary>
/// <param name="parTag">The tag id</param>
/// <param name="parData">The replacement-data for the tag</param>
public void Add(string parTag, string parData)
{
_dict.Add(new KeyValuePair<string, string>(parTag, parData));
}
/// <summary>
/// Adds tag and json-serialized replacement-data pair to parameters
/// </summary>
/// <param name="parTag">The tag id</param>
/// <param name="parData">The replacement-data object for the tag</param>
public void Add(string parTag, object parData)
{
_dict.Add(new KeyValuePair<string, string>(parTag, Converter.Serialize(parData)));
}
/// <summary>
/// Returns the enumeration of tag and replacement-data pairs
/// </summary>
/// <returns>Pairs of tag and replacement-data</returns>
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
{
return _dict.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}