Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
GenericObjectPropertyEnumerator.cs
1using System;
2using System.Collections.Generic;
9using System.Threading.Tasks;
10
12{
17 {
22 {
23 }
24
30 public Task<IElement> EnumerateProperties(object Object)
31 {
32 if (Object is GenericObject Obj)
33 {
34 List<IElement> Elements = new List<IElement>();
35
36 if (!string.IsNullOrEmpty(Obj.CollectionName) && !Obj.TryGetFieldValue("CollectionName", out object _))
37 {
38 Elements.Add(new StringValue("CollectionName"));
39 Elements.Add(Expression.Encapsulate(Obj.CollectionName));
40 }
41
42 if (!string.IsNullOrEmpty(Obj.TypeName) && !Obj.TryGetFieldValue("TypeName", out object _))
43 {
44 Elements.Add(new StringValue("TypeName"));
45 Elements.Add(Expression.Encapsulate(Obj.TypeName));
46 }
47
48 if (Obj.ObjectId != Guid.Empty && !Obj.TryGetFieldValue("ObjectId", out object _))
49 {
50 Elements.Add(new StringValue("ObjectId"));
51 Elements.Add(Expression.Encapsulate(Obj.ObjectId));
52 }
53
54 foreach (KeyValuePair<string, object> P in Obj.Properties)
55 {
56 Elements.Add(new StringValue(P.Key));
57 Elements.Add(Expression.Encapsulate(P.Value));
58 }
59
60 ObjectMatrix M = new ObjectMatrix(Elements.Count / 2, 2, Elements)
61 {
62 ColumnNames = new string[] { "Name", "Value" }
63 };
64
65 return Task.FromResult<IElement>(M);
66 }
67 else
68 return Task.FromResult<IElement>(ObjectValue.Null);
69 }
70
76 public Grade Supports(Type Object)
77 {
78 if (Object == typeof(GenericObject))
79 return Grade.Ok;
80 else
81 return Grade.NotAtAll;
82 }
83 }
84}
Generic object. Contains a sequence of properties.
Class managing a script expression.
Definition: Expression.cs:39
static IElement Encapsulate(object Value)
Encapsulates an object.
Definition: Expression.cs:4955
static readonly ObjectValue Null
Null value.
Definition: ObjectValue.cs:86
GenericObjectPropertyEnumerator()
Enumerates properties in a GenericObject object.
Grade Supports(Type Object)
If the interface understands objects such as Object .
Task< IElement > EnumerateProperties(object Object)
Enumerates the properties of an object (of a type it supports).
Basic interface for all types of elements.
Definition: IElement.cs:20
Grade
Grade enumeration
Definition: Grade.cs:7