Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
StringToUInt16.cs
1using System;
2using System.Globalization;
5
7{
12 {
16 public Type From => typeof(string);
17
21 public Type To => typeof(ushort);
22
28 public double Weight => 0.5;
29
36 public bool TryConvert(object Value, out object Result)
37 {
38 if (Value is string s && ushort.TryParse(s, NumberStyles.Integer, null, out ushort i))
39 {
40 Result = i;
41 return true;
42 }
43 else
44 {
45 Result = null;
46 return false;
47 }
48 }
49
57 public bool TryConvertToElement(object Value, out IElement Result)
58 {
59 if (Value is string s && ushort.TryParse(s, NumberStyles.Integer, null, out ushort i))
60 {
61 Result = new ObjectValue(i);
62 return true;
63 }
64 else
65 {
66 Result = null;
67 return false;
68 }
69 }
70 }
71}
Converts string values to 16-bit unsigned integer values.
bool TryConvertToElement(object Value, out IElement Result)
Converts the object in Value to an object of type To, encapsulated in an IElement.
bool TryConvert(object Value, out object Result)
Converts the object in Value to an object of type To.
Type From
Converts string values to 16-bit unsigned integer values.
Type To
Converter converts objects to this type.
double Weight
Weight of the converter. An estimate of how well the converter performs, or how much information is r...
Basic interface for all types of elements.
Definition: IElement.cs:21
Converts an object of one type to an object of another type.