Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
EnumHostSetting.cs
1using System;
4
6{
11 {
12 private Enum value = null;
13 private Type enumType = null;
14 private string enumTypeName = string.Empty;
15 private string enumValue = string.Empty;
16
21 {
22 }
23
30 public EnumHostSetting(string Host, string Key, Enum Value)
31 : base(Host, Key)
32 {
33 this.Value = Value;
34 }
35
39 [IgnoreMember]
40 public Enum Value
41 {
42 get
43 {
44 if (this.value is null)
45 this.value = (Enum)Enum.Parse(this.enumType, this.enumValue);
46
47 return this.value;
48 }
49
50 set
51 {
52 this.enumType = value.GetType();
53 this.enumTypeName = this.enumType.FullName;
54 this.enumValue = value.ToString();
55 this.value = null;
56 }
57 }
58
62 [DefaultValueStringEmpty]
63 public string EnumTypeName
64 {
65 get => this.enumTypeName;
66 set
67 {
68 this.enumType = Types.GetType(value);
69 if (this.enumType is null)
70 throw new InvalidOperationException("Enumeration type not recognized by " + typeof(Types).Namespace + ": " + value);
71
72 this.enumTypeName = value;
73 this.value = null;
74 }
75 }
76
80 [DefaultValueStringEmpty]
81 public string EnumValue
82 {
83 get => this.enumValue;
84 set
85 {
86 this.enumValue = value;
87 this.value = null;
88 }
89 }
90
95 public override object GetValueObject()
96 {
97 return this.Value;
98 }
99 }
100}
Static class that dynamically manages types and interfaces available in the runtime environment.
Definition: Types.cs:14
static Type GetType(string FullName)
Gets a type, given its full name.
Definition: Types.cs:41
EnumHostSetting(string Host, string Key, Enum Value)
Enumeration setting object.
override object GetValueObject()
Gets the value of the setting, as an object.
Base abstract class for host settings.
Definition: HostSetting.cs:15