Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
StringToInt8.cs
1using System;
2using System.Globalization;
5
7{
12 {
16 public Type From => typeof(string);
17
21 public Type To => typeof(sbyte);
22
28 public double Weight => 0.5;
29
36 public bool TryConvert(object Value, out object Result)
37 {
38 if (Value is string s && sbyte.TryParse(s, NumberStyles.Integer, null, out sbyte 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 && sbyte.TryParse(s, NumberStyles.Integer, null, out sbyte 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 8-bit integer values.
Definition: StringToInt8.cs:12
Type To
Converter converts objects to this type.
Definition: StringToInt8.cs:21
double Weight
Weight of the converter. An estimate of how well the converter performs, or how much information is r...
Definition: StringToInt8.cs:28
Type From
Converts string values to 8-bit integer values.
Definition: StringToInt8.cs:16
bool TryConvert(object Value, out object Result)
Converts the object in Value to an object of type To.
Definition: StringToInt8.cs:36
bool TryConvertToElement(object Value, out IElement Result)
Converts the object in Value to an object of type To, encapsulated in an IElement.
Definition: StringToInt8.cs:57
Basic interface for all types of elements.
Definition: IElement.cs:21
Converts an object of one type to an object of another type.