Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ScriptElementEncoder.cs
1using System;
2using System.Reflection;
3using System.Text;
5using Waher.Script;
7
9{
14 {
19 {
20 }
21
28 public void Encode(object Object, int? Indent, StringBuilder Json)
29 {
30 IElement E = (IElement)Object;
31 object Obj = E.AssociatedObjectValue;
32
33 if (E.Equals(Obj))
34 {
35 string s = Expression.ToString(Obj);
36 JSON.Encode(s, Indent, Json);
37 }
38 else
39 JSON.Encode(Obj, Indent, Json);
40 }
41
47 public Grade Supports(Type ObjectType)
48 {
49 if (typeof(IElement).GetTypeInfo().IsAssignableFrom(ObjectType.GetTypeInfo()) &&
50 !typeof(IVector).GetTypeInfo().IsAssignableFrom(ObjectType.GetTypeInfo()))
51 {
52 return Grade.Ok;
53 }
54 else
55 return Grade.NotAtAll;
56 }
57 }
58}
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 .
Class managing a script expression.
Definition: Expression.cs:39
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Definition: Expression.cs:4496
Interface for encoding objects of certain types to JSON.
Definition: IJsonEncoder.cs:11
Basic interface for all types of elements.
Definition: IElement.cs:20
object AssociatedObjectValue
Associated object value.
Definition: IElement.cs:33
Basic interface for vectors.
Definition: IVector.cs:9
Grade
Grade enumeration
Definition: Grade.cs:7