-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathProjectDirectoryCollection.cs
More file actions
109 lines (91 loc) · 2.23 KB
/
Copy pathProjectDirectoryCollection.cs
File metadata and controls
109 lines (91 loc) · 2.23 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using RPGCore.Packages;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
namespace RPGCore.Projects;
[DebuggerDisplay("Count = {Count,nq}")]
[DebuggerTypeProxy(typeof(ProjectDirectoryCollectionDebugView))]
public sealed class ProjectDirectoryCollection : IDirectoryCollection
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly List<ProjectDirectory> directories;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public int Count => directories.Count;
public ProjectDirectory this[string key]
{
get
{
foreach (var directory in directories)
{
if (directory.Name == key)
{
return directory;
}
}
return null;
}
}
public ProjectDirectory this[int key] => directories[key];
IDirectory IReadOnlyList<IDirectory>.this[int key] => this[key];
internal ProjectDirectoryCollection()
{
directories = new List<ProjectDirectory>();
}
internal void Add(ProjectDirectory item)
{
directories.Add(item);
}
public IEnumerator<ProjectDirectory> GetEnumerator()
{
return directories.GetEnumerator();
}
IEnumerator<IDirectory> IEnumerable<IDirectory>.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
private class ProjectDirectoryCollectionDebugView
{
[DebuggerDisplay("{Value}", Name = "{Key}")]
internal struct DebuggerRow
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public string Key;
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public IDirectory Value;
}
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly ProjectDirectoryCollection source;
public ProjectDirectoryCollectionDebugView(ProjectDirectoryCollection source)
{
this.source = source;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public DebuggerRow[] Keys
{
get
{
if (source.directories == null
|| source.directories.Count == 0)
{
return null;
}
var keys = new DebuggerRow[source.directories.Count];
int i = 0;
foreach (var directory in source.directories)
{
keys[i] = new DebuggerRow
{
Key = directory.Name,
Value = directory
};
i++;
}
return keys;
}
}
}
}