Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
StringToCiString.cs
1using System;
6
8{
13 {
17 public Type From => typeof(string);
18
22 public Type To => typeof(CaseInsensitiveString);
23
29 public double Weight => 1.0;
30
37 public bool TryConvert(object Value, out object Result)
38 {
39 if (Value is null)
40 {
41 Result = null;
42 return true;
43 }
44 else if (Value is string s)
45 {
46 Result = (CaseInsensitiveString)s;
47 return true;
48 }
49 else
50 {
51 Result = null;
52 return false;
53 }
54 }
55
63 public bool TryConvertToElement(object Value, out IElement Result)
64 {
65 if (Value is null)
66 {
67 Result = ObjectValue.Null;
68 return true;
69 }
70 else if (Value is string s)
71 {
72 Result = new ObjectValue((CaseInsensitiveString)s);
73 return true;
74 }
75 else
76 {
77 Result = null;
78 return false;
79 }
80 }
81 }
82}
Represents a case-insensitive string.
static readonly ObjectValue Null
Null value.
Definition: ObjectValue.cs:88
Converts normal strings to case-insensitive strings.
bool TryConvert(object Value, out object Result)
Converts the object in Value to an object of type To.
Type From
Converter converts objects of this type.
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...
bool TryConvertToElement(object Value, out IElement Result)
Converts the object in Value to an object of type To, encapsulated in an IElement.
Basic interface for all types of elements.
Definition: IElement.cs:21
Converts an object of one type to an object of another type.