-
Notifications
You must be signed in to change notification settings - Fork 866
Expand file tree
/
Copy pathKeywordCollection.cs
More file actions
63 lines (52 loc) · 1.68 KB
/
KeywordCollection.cs
File metadata and controls
63 lines (52 loc) · 1.68 KB
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
using System.Collections;
using System.Collections.Generic;
namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
internal class KeywordCollection : IEnumerable<KeywordCollection.Item>
{
public class Item : IConditional
{
public KeywordDescriptor descriptor { get; }
public FieldCondition[] fieldConditions { get; }
public Item(KeywordDescriptor descriptor, FieldCondition[] fieldConditions)
{
this.descriptor = descriptor;
this.fieldConditions = fieldConditions;
}
}
readonly List<Item> m_Items;
public KeywordCollection()
{
m_Items = new List<Item>();
}
public KeywordCollection Add(KeywordCollection keywords)
{
m_Items.AddRange(keywords);
return this;
}
public KeywordCollection Add(KeywordDescriptor descriptor)
{
m_Items.Add(new Item(descriptor, null));
return this;
}
public KeywordCollection Add(KeywordDescriptor descriptor, FieldCondition fieldCondition)
{
m_Items.Add(new Item(descriptor, new FieldCondition[] { fieldCondition }));
return this;
}
public KeywordCollection Add(KeywordDescriptor descriptor, FieldCondition[] fieldConditions)
{
m_Items.Add(new Item(descriptor, fieldConditions));
return this;
}
public IEnumerator<Item> GetEnumerator()
{
return m_Items.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}