Skip to content

Commit 8a746fb

Browse files
committed
Initial commit
0 parents  commit 8a746fb

636 files changed

Lines changed: 42899 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
obj
2+
obj.meta
3+
Library
4+
Temp
5+
6+
./*.csproj
7+
./*.sln
8+
./*.userprefs
9+
*.unityproj
10+
*.suo
11+
*.user
12+
*.pidb
13+
*.userprefs
14+
*.userprefs.meta
15+
Builds
16+
UnitTestResults.xml*
17+
*-TestResults.xml*
18+
19+
# ignore these specifically since the ./*.ext approach isn't working
20+
Assembly-CSharp-Editor-vs.csproj
21+
Assembly-CSharp-Editor.csproj
22+
Assembly-CSharp-vs.csproj
23+
Assembly-CSharp.csproj
24+
DarkConfig-csharp.sln
25+
DarkConfig.sln
26+
players
27+
plainlog.txt
28+
DLL/Debug/Editor/Mono.*
29+
DLL/Debug/Editor/Unity*

Assets/DarkConfig.meta

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/DarkConfig/AssemblyInfo.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
// Information about this assembly is defined by the following attributes.
5+
// Change them to the values specific to your project.
6+
7+
[assembly: AssemblyTitle("DarkConfig")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("")]
12+
[assembly: AssemblyCopyright("Spry Fox")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
16+
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17+
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
18+
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
19+
20+
[assembly: AssemblyVersion("0.3.1.1")]
21+
22+
// The following attributes are used to specify the signing key for the assembly,
23+
// if desired. See the Mono documentation for more information about signing.
24+
25+
//[assembly: AssemblyDelaySign(false)]
26+
//[assembly: AssemblyKeyFile("")]
27+

Assets/DarkConfig/AssemblyInfo.cs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/DarkConfig/Attributes.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
3+
// If the field annotated with a Mandatory, or any field on a Mandatory class,
4+
// is not present in the YAML, DarkConfig will complain, regardless of other
5+
// settings.
6+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class | AttributeTargets.Struct)]
7+
public class ConfigMandatoryAttribute : Attribute {
8+
}
9+
10+
// If an AllowMissing field, or any field on an AllowMissing class, is not
11+
// present in the YAML, DarkConfig will not complain, regardless of other
12+
// settings.
13+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class | AttributeTargets.Struct)]
14+
public class ConfigAllowMissingAttribute : Attribute {
15+
}
16+
17+
// If a field has the Ignore attribute, it will be completely ignored by
18+
// DarkConfig; not set, not checked, it's as if it wasn't on the class in the
19+
// first place.
20+
[AttributeUsage(AttributeTargets.Field)]
21+
public class ConfigIgnoreAttribute : Attribute {
22+
}

Assets/DarkConfig/Attributes.cs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
using System.Collections.Generic;
2+
3+
namespace DarkConfig {
4+
5+
/// <summary>
6+
/// ComposedDocNode is a mutable DocNode implementation, intended to be used to
7+
/// help compiling multiple source documents into one meta-document.
8+
/// </summary>
9+
public class ComposedDocNode : DocNode {
10+
//////////////////////////////////////////////////////////////////////
11+
// DocNode Methods
12+
//////////////////////////////////////////////////////////////////////
13+
public ComposedDocNode(DocNodeType type, int size = -1) {
14+
m_type = type;
15+
switch(type) {
16+
case DocNodeType.Invalid:
17+
break;
18+
case DocNodeType.Dictionary:
19+
if(size > 0) m_dictionary = new Dictionary<string, DocNode>(size);
20+
else m_dictionary = new Dictionary<string, DocNode>();
21+
break;
22+
case DocNodeType.List:
23+
if(size > 0) m_list = new List<DocNode>(size);
24+
else m_list = new List<DocNode>();
25+
break;
26+
case DocNodeType.Scalar:
27+
m_scalar = "";
28+
break;
29+
}
30+
}
31+
32+
public override DocNodeType Type {
33+
get {
34+
return m_type;
35+
}
36+
}
37+
38+
void AssertTypeIs(DocNodeType type) {
39+
if (Type != type) {
40+
ThrowAccessException(type.ToString(), Type.ToString());
41+
}
42+
}
43+
44+
static System.Text.StringBuilder s_exceptionBuilder = new System.Text.StringBuilder(500);
45+
void ThrowAccessException(string expectedType, string actualType) {
46+
s_exceptionBuilder.Length = 0;
47+
s_exceptionBuilder.Append("Accessing ComposedDocNode as ");
48+
s_exceptionBuilder.Append(expectedType);
49+
s_exceptionBuilder.Append(" but is ");
50+
s_exceptionBuilder.Append(actualType);
51+
s_exceptionBuilder.Append(". ");
52+
throw new DocNodeAccessException(s_exceptionBuilder.ToString());
53+
}
54+
55+
// access the node as if it was a list
56+
public override DocNode this[int index] {
57+
get {
58+
AssertTypeIs(DocNodeType.List);
59+
return m_list[index];
60+
}
61+
set {
62+
throw new System.NotImplementedException();
63+
}
64+
}
65+
66+
// access the node as if it was a Dictionary
67+
public override DocNode this[string key] {
68+
get {
69+
AssertTypeIs(DocNodeType.Dictionary);
70+
return m_dictionary[key];
71+
}
72+
set {
73+
AssertTypeIs(DocNodeType.Dictionary);
74+
m_dictionary[key] = value;
75+
}
76+
}
77+
78+
public override int Count {
79+
get {
80+
if (Type != DocNodeType.Dictionary && Type != DocNodeType.List) {
81+
ThrowAccessException("Countable (Dictionary or List)", Type.ToString());
82+
}
83+
if (Type == DocNodeType.Dictionary) {
84+
return m_dictionary.Count;
85+
}
86+
if (Type == DocNodeType.List) {
87+
return m_list.Count;
88+
}
89+
throw new System.NotImplementedException();
90+
}
91+
}
92+
93+
public override bool ContainsKey(string key) {
94+
AssertTypeIs(DocNodeType.Dictionary);
95+
return m_dictionary.ContainsKey(key);
96+
}
97+
98+
public override IEnumerable<DocNode> Values {
99+
get {
100+
AssertTypeIs(DocNodeType.List);
101+
return m_list;
102+
}
103+
}
104+
105+
public override IEnumerable<KeyValuePair<string, DocNode>> Pairs {
106+
get {
107+
AssertTypeIs(DocNodeType.Dictionary);
108+
return m_dictionary;
109+
}
110+
}
111+
112+
public override string StringValue {
113+
get {
114+
AssertTypeIs(DocNodeType.Scalar);
115+
return m_scalar;
116+
}
117+
set {
118+
AssertTypeIs(DocNodeType.Scalar);
119+
m_scalar = value;
120+
}
121+
}
122+
123+
public override string SourceInformation {
124+
get {
125+
return "ComposedDocNode " + Type;
126+
}
127+
}
128+
129+
public override string ToString() {
130+
return string.Format("ComposedDocNode({0}, {1})", Type,
131+
(Type == DocNodeType.Scalar ? m_scalar : Count.ToString()));
132+
}
133+
134+
//////////////////////////////////////////////////////////////////////
135+
// Composition methods
136+
137+
public void Add(DocNode d) {
138+
AssertTypeIs(DocNodeType.List);
139+
m_list.Add(d);
140+
}
141+
142+
public void Add(string key, DocNode value) {
143+
AssertTypeIs(DocNodeType.Dictionary);
144+
m_dictionary.Add(key, value);
145+
}
146+
147+
////////////////////////////////////////////
148+
DocNodeType m_type;
149+
Dictionary<string, DocNode> m_dictionary;
150+
List<DocNode> m_list;
151+
string m_scalar;
152+
}
153+
154+
}

Assets/DarkConfig/ComposedDocNode.cs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)