Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DefaultPropertyEnumerator.cs
1using System;
2using System.Collections.Generic;
3using System.Reflection;
9using System.Threading.Tasks;
10
12{
17 {
22 {
23 }
24
30 public async Task<IElement> EnumerateProperties(object Object)
31 {
32 List<IElement> Elements = new List<IElement>();
33 Type T = Object.GetType();
34 IElement Value;
35
36 foreach (PropertyInfo PI in T.GetRuntimeProperties())
37 {
38 if (!PI.CanRead || !PI.GetMethod.IsPublic || PI.GetIndexParameters().Length > 0)
39 continue;
40
41 Elements.Add(new StringValue(PI.Name));
42
43 try
44 {
45 Value = Expression.Encapsulate(await ScriptNode.WaitPossibleTask(PI.GetValue(Object)));
46 }
47 catch (Exception ex)
48 {
49 Value = new ObjectValue(ex);
50 }
51
52 Elements.Add(Value);
53 }
54
55 ObjectMatrix M = new ObjectMatrix(Elements.Count / 2, 2, Elements)
56 {
57 ColumnNames = new string[] { "Name", "Value" }
58 };
59
60 return M;
61 }
62
68 public Grade Supports(Type Object)
69 {
70 return Grade.Barely;
71 }
72 }
73}
Class managing a script expression.
Definition: Expression.cs:39
static IElement Encapsulate(object Value)
Encapsulates an object.
Definition: Expression.cs:4955
Grade Supports(Type Object)
If the interface understands objects such as Object .
async Task< IElement > EnumerateProperties(object Object)
Enumerates the properties of an object (of a type it supports).
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
static async Task< object > WaitPossibleTask(object Result)
Waits for any asynchronous process to terminate.
Definition: ScriptNode.cs:417
Basic interface for all types of elements.
Definition: IElement.cs:20
Grade
Grade enumeration
Definition: Grade.cs:7