Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DateTimeValue.cs
1using System;
2using System.Reflection;
5
7{
11 public sealed class DateTimeValue : Element
12 {
13 private static readonly DateTimeValues associatedSet = new DateTimeValues();
14
15 private DateTime value;
16
21 public DateTimeValue(DateTime Value)
22 {
23 this.value = Value;
24 }
25
29 public DateTime Value
30 {
31 get => this.value;
32 set => this.value = value;
33 }
34
36 public override string ToString()
37 {
38 return Expression.ToString(this.value);
39 }
40
44 public override ISet AssociatedSet
45 {
46 get { return associatedSet; }
47 }
48
52 public override object AssociatedObjectValue => this.value;
53
55 public override bool Equals(object obj)
56 {
57 if (!(obj is IElement E) || !(E.AssociatedObjectValue is DateTime TP))
58 return false;
59 else
60 return this.value == TP;
61 }
62
64 public override int GetHashCode()
65 {
66 return this.value.GetHashCode();
67 }
68
75 public override bool TryConvertTo(Type DesiredType, out object Value)
76 {
77 if (DesiredType == typeof(DateTime))
78 {
79 Value = this.value;
80 return true;
81 }
82 else if (DesiredType == typeof(DateTimeOffset))
83 {
84 Value = (DateTimeOffset)this.value;
85 return true;
86 }
87 else if (DesiredType == typeof(DateTimeValue))
88 {
89 Value = this;
90 return true;
91 }
92 else if (DesiredType.GetTypeInfo().IsAssignableFrom(typeof(DateTime).GetTypeInfo()))
93 {
94 Value = this.value;
95 return true;
96 }
97 else
98 return Expression.TryConvert(this.value, DesiredType, out Value);
99 }
100 }
101}
Base class for all types of elements.
Definition: Element.cs:13
Class managing a script expression.
Definition: Expression.cs:39
static bool TryConvert(object Value, Type DesiredType, out object Result)
Tries to convert an object Value to an object of type DesiredType .
Definition: Expression.cs:5268
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Definition: Expression.cs:4496
override int GetHashCode()
Calculates a hash code of the element. Hash code.
DateTime Value
DateTime value.
override ISet AssociatedSet
Associated Set.
DateTimeValue(DateTime Value)
DateTime-valued number.
override bool TryConvertTo(Type DesiredType, out object Value)
Converts the value to a .NET type.
override bool Equals(object obj)
Compares the element to another. If elements are equal.
override object AssociatedObjectValue
Associated object value.
The set of Date & Time values.
Basic interface for all types of elements.
Definition: IElement.cs:20
Basic interface for all types of sets.
Definition: ISet.cs:10