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
51 public IEnumerator<BadObject> GetEnumerator()
52 {
53 return ((IEnumerable<BadObject>)InnerArray).GetEnumerator();
54 }
55
60 IEnumerator IEnumerable.GetEnumerator()
61 {
62 return GetEnumerator();
63 }
64
67 {
68 return Prototype;
69 }
70
71
73 public override string ToSafeString(List<BadObject> done)
74 {
75 done.Add(this);
76 StringBuilder sb = new StringBuilder();
77 sb.Append("[");
78 sb.AppendLine();
79
80 foreach (BadObject element in InnerArray)
81 {
82 string str = "{...}";
83
84 if (!done.Contains(element))
85 {
86 str = element.ToSafeString(done).Trim();
87 }
88
89 if (str.Contains("\n"))
90 {
91 str = str.Replace("\n", "\n\t");
92 }
93
94 sb.AppendLine($"\t{str}");
95 }
96
97 sb.AppendLine("]");
98
99 return sb.ToString();
100 }
101
103 public override string ToString()
104 {
105 StringBuilder sb = new StringBuilder();
106 sb.Append("[");
107 sb.AppendLine();
108
109 foreach (BadObject element in InnerArray)
110 {
111 if (element is BadScope)
112 {
113 sb.AppendLine("RECURSION_PROTECT");
114
115 continue;
116 }
117
118 string str = element.ToString().Trim();
119
120 if (str.Contains("\n"))
121 {
122 str = str.Replace("\n", "\n\t");
123 }
124
125 sb.AppendLine($"\t{str}");
126 }
127
128 sb.AppendLine("]");
129
130 return sb.ToString();
131 }
132}
Implements the Scope for the Script Engine.
Definition BadScope.cs:238
Implements a Dynamic List/Array for the BadScript Language.
Definition BadArray.cs:17
override BadClassPrototype GetPrototype()
Definition BadArray.cs:66
override string ToSafeString(List< BadObject > done)
Definition BadArray.cs:73
IEnumerator< BadObject > GetEnumerator()
Returns the Enumerator for this Array.
Definition BadArray.cs:51
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:210
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