Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MarkdownElementChildren.cs
1using System.Collections.Generic;
2using System.Threading.Tasks;
3
5{
10 {
11 private IEnumerable<MarkdownElement> children;
12
18 public MarkdownElementChildren(MarkdownDocument Document, IEnumerable<MarkdownElement> Children)
19 : base(Document)
20 {
21 this.children = Children;
22 }
23
30 : base(Document)
31 {
32 this.children = Children;
33 }
34
39 public void AddChildren(params MarkdownElement[] NewChildren)
40 {
41 this.AddChildren((IEnumerable<MarkdownElement>)NewChildren);
42 }
43
48 public virtual void AddChildren(IEnumerable<MarkdownElement> NewChildren)
49 {
50 if (!(this.children is LinkedList<MarkdownElement> Children))
51 {
52 Children = new LinkedList<MarkdownElement>();
53
54 foreach (MarkdownElement E in this.children)
55 Children.AddLast(E);
56
57 this.children = Children;
58 }
59
60 foreach (MarkdownElement E in NewChildren)
61 Children.AddLast(E);
62 }
63
68 {
69 get
70 {
71 foreach (MarkdownElement E in this.children)
72 return E;
73
74 return null;
75 }
76 }
77
82 {
83 get
84 {
85 MarkdownElement Result = null;
86
87 foreach (MarkdownElement E in this.children)
88 Result = E;
89
90 return Result;
91 }
92 }
93
97 public bool HasOneChild
98 {
99 get
100 {
101 bool First = true;
102
103 foreach (MarkdownElement E in this.children)
104 {
105 if (First)
106 First = false;
107 else
108 return false;
109 }
110
111 return !First;
112 }
113 }
114
118 public override IEnumerable<MarkdownElement> Children => this.children;
119
124 protected void SetChildren(IEnumerable<MarkdownElement> Children)
125 {
126 this.children = Children;
127 }
128
136 public abstract MarkdownElementChildren Create(IEnumerable<MarkdownElement> Children, MarkdownDocument Document);
137
141 internal virtual bool JoinOverParagraphs => false;
142
149 public override bool ForEach(MarkdownElementHandler Callback, object State)
150 {
151 if (!Callback(this, State))
152 return false;
153
154 if (!(this.children is null))
155 {
156 foreach (MarkdownElement E in this.children)
157 {
158 if (!E.ForEach(Callback, State))
159 return false;
160 }
161 }
162
163 return true;
164 }
165
171 public override bool Equals(object obj)
172 {
173 if (!(obj is MarkdownElementChildren x) || !base.Equals(obj))
174 return false;
175
176 IEnumerator<MarkdownElement> e1 = this.children.GetEnumerator();
177 IEnumerator<MarkdownElement> e2 = x.children.GetEnumerator();
178 bool b1, b2;
179
180 while (true)
181 {
182 b1 = e1.MoveNext();
183 b2 = e2.MoveNext();
184
185 if (b1 ^ b2)
186 return false;
187
188 if (!b1)
189 return true;
190
191 if (!e1.Current.Equals(e2.Current))
192 return false;
193 }
194 }
195
200 public override int GetHashCode()
201 {
202 int h1 = base.GetHashCode();
203 int h2;
204
205 foreach (MarkdownElement E in this.children)
206 {
207 h2 = E.GetHashCode();
208 h1 = ((h1 << 5) + h1) ^ h2;
209 }
210
211 return h1;
212 }
213
214 }
215}
Contains a markdown document. This markdown document class supports original markdown,...
Abstract base class for all markdown elements with a variable number of child elements.
void SetChildren(IEnumerable< MarkdownElement > Children)
Sets the children of the node.
override IEnumerable< MarkdownElement > Children
Any children of the element.
MarkdownElement LastChild
Last child, or null if none.
abstract MarkdownElementChildren Create(IEnumerable< MarkdownElement > Children, MarkdownDocument Document)
Creates an object of the same type, and meta-data, as the current object, but with content defined by...
override int GetHashCode()
Serves as the default hash function.
override bool Equals(object obj)
Determines whether the specified object is equal to the current object.
void AddChildren(params MarkdownElement[] NewChildren)
Adds children to the element.
MarkdownElementChildren(MarkdownDocument Document, params MarkdownElement[] Children)
Abstract base class for all markdown elements with a variable number of child elements.
override bool ForEach(MarkdownElementHandler Callback, object State)
Loops through all child-elements for the element.
virtual void AddChildren(IEnumerable< MarkdownElement > NewChildren)
Adds children to the element.
MarkdownElementChildren(MarkdownDocument Document, IEnumerable< MarkdownElement > Children)
Abstract base class for all markdown elements with a variable number of child elements.
bool HasOneChild
If the element has only one child.
MarkdownElement FirstChild
First child, or null if none.
Abstract base class for all markdown elements.
virtual bool ForEach(MarkdownElementHandler Callback, object State)
Loops through all child-elements for the element.
override int GetHashCode()
Serves as the default hash function.
MarkdownDocument Document
Markdown document.
delegate bool MarkdownElementHandler(MarkdownElement Element, object State)
Delegate for markdown element callback methods.