BadScript 2
Loading...
Searching...
No Matches
BadArray.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Text;
3
6
11
16
17{
22
27 public BadArray(List<BadObject> innerArray)
28 {
29 InnerArray = innerArray;
30 }
31
35 public BadArray() : this(new List<BadObject>()) { }
36
41
45 public List<BadObject> InnerArray { get; }
46
47#region IBadEnumerable Members
48
53 public IEnumerator<BadObject> GetEnumerator()
54 {
55 return ((IEnumerable<BadObject>)InnerArray).GetEnumerator();
56 }
57
62 IEnumerator IEnumerable.GetEnumerator()
63 {
64 return GetEnumerator();
65 }
66
67#endregion
68
71 {
72 return Prototype;
73 }
74
75
77 public override string ToSafeString(List<BadObject> done)
78 {
79 done.Add(this);
80 StringBuilder sb = new StringBuilder();
81 sb.Append("[");
82 sb.AppendLine();
83
84 foreach (BadObject element in InnerArray)
85 {
86 string str = "{...}";
87
88 if (!done.Contains(element))
89 {
90 str = element.ToSafeString(done)
91 .Trim();
92 }
93
94 if (str.Contains("\n"))
95 {
96 str = str.Replace("\n", "\n\t");
97 }
98
99 sb.AppendLine($"\t{str}");
100 }
101
102 sb.AppendLine("]");
103
104 return sb.ToString();
105 }
106
108 public override string ToString()
109 {
110 StringBuilder sb = new StringBuilder();
111 sb.Append("[");
112 sb.AppendLine();
113
114 foreach (BadObject element in InnerArray)
115 {
116 if (element is BadScope)
117 {
118 sb.AppendLine("RECURSION_PROTECT");
119
120 continue;
121 }
122
123 string str = element.ToString()
124 .Trim();
125
126 if (str.Contains("\n"))
127 {
128 str = str.Replace("\n", "\n\t");
129 }
130
131 sb.AppendLine($"\t{str}");
132 }
133
134 sb.AppendLine("]");
135
136 return sb.ToString();
137 }
138}
Implements the Scope for the Script Engine.
Definition BadScope.cs:16
Implements a Dynamic List/Array for the BadScript Language.
Definition BadArray.cs:17
override BadClassPrototype GetPrototype()
Definition BadArray.cs:70
override string ToSafeString(List< BadObject > done)
Definition BadArray.cs:77
IEnumerator< BadObject > GetEnumerator()
Returns the Enumerator for this Array.
Definition BadArray.cs:53
static BadClassPrototype Prototype
The Prototype for the BadScript Array.
Definition BadArray.cs:40
BadArray(List< BadObject > innerArray)
Creates a new Instance of the BadScript Array.
Definition BadArray.cs:27
static ? BadClassPrototype s_Prototype
The Prototype for the BadScript Array.
Definition BadArray.cs:21
BadArray()
Creates a new Instance of the BadScript Array.
Definition BadArray.cs:35
List< BadObject > InnerArray
The Inner Array.
Definition BadArray.cs:45
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
string ToSafeString(List< BadObject > done)
Returns a String Representation of this Object. This function is recursion proof and supports circula...
override string ToString()
Returns a String Representation of this Object.
Definition BadObject.cs:224
Implements a Class Prototype for the BadScript Language.
Helper Class that Builds a Native Class from a Prototype.
static BadClassPrototype GetNative(string name)
Returns a Native Class Prototype for the given Native Type.
Defines a BadScript Enumerable.
Contains the Interop Abstractions and Implementations for the BadScript2 Language.
Contains the Runtime Objects.
Definition BadArray.cs:10