Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
BooleanToDouble.cs
1using System;
2using System.Numerics;
5
7{
12 {
16 public Type From => typeof(bool);
17
21 public Type To => typeof(double);
22
28 public double Weight => 1.0;
29
36 public bool TryConvert(object Value, out object Result)
37 {
38 if (Value is bool b)
39 {
40 Result = b ? 1.0 : 0.0;
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 bool b)
60 {
61 Result = new DoubleNumber(b ? 1 : 0);
62 return true;
63 }
64 else
65 {
66 Result = null;
67 return false;
68 }
69 }
70 }
71}
Converts a Boolean value to a double number.
Type From
Converter converts objects of this type.
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 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.