Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
VectorEncoder.cs
1using System;
2using System.Reflection;
3using System.Text;
6
8{
13 {
18 {
19 }
20
27 public void Encode(object Object, int? Indent, StringBuilder Json)
28 {
29 IVector V = (IVector)Object;
30 bool First = true;
31
32 Json.Append('[');
33
34 if (Indent.HasValue)
35 Indent++;
36
37 foreach (IElement Element in V.VectorElements)
38 {
39 if (First)
40 First = false;
41 else
42 Json.Append(',');
43
44 if (Indent.HasValue)
45 {
46 Json.AppendLine();
47 Json.Append(new string('\t', Indent.Value));
48 }
49
51 }
52
53 if (Indent.HasValue)
54 {
55 Indent--;
56
57 if (!First)
58 {
59 Json.AppendLine();
60 Json.Append(new string('\t', Indent.Value));
61 }
62 }
63
64 Json.Append(']');
65 }
66
72 public Grade Supports(Type ObjectType)
73 {
74 return typeof(IVector).GetTypeInfo().IsAssignableFrom(ObjectType.GetTypeInfo()) ? Grade.Ok : Grade.NotAtAll;
75 }
76 }
77}
Helps with common JSON-related tasks.
Definition: JSON.cs:14
static string Encode(string s)
Encodes a string for inclusion in JSON.
Definition: JSON.cs:507
void Encode(object Object, int? Indent, StringBuilder Json)
Encodes the Object to JSON.
Grade Supports(Type ObjectType)
How well the JSON encoder encodes objects of type ObjectType .
Base class for all types of elements.
Definition: Element.cs:13
abstract object AssociatedObjectValue
Associated object value.
Definition: Element.cs:46
Interface for encoding objects of certain types to JSON.
Definition: IJsonEncoder.cs:11
Basic interface for all types of elements.
Definition: IElement.cs:20
Basic interface for vectors.
Definition: IVector.cs:9
Grade
Grade enumeration
Definition: Grade.cs:7