2using System.Collections.Generic;
3using System.Reflection;
18 private string valueLower =
null;
19 private bool caseInsensitive;
28 this.caseInsensitive =
false;
48 set => this.value = value;
56 get => this.caseInsensitive;
57 set => this.caseInsensitive = value;
73 if (this.caseInsensitive)
74 return associatedSemiGroupCis;
76 return associatedSemiGroup;
96 LinkedList<IElement> Elements =
new LinkedList<IElement>();
105 Elements.AddLast(this.
AddLeft(SE));
123 LinkedList<IElement> Elements =
new LinkedList<IElement>();
132 Elements.AddLast(this.
AddRight(SE));
143 return string.Compare(this.value, S.value,
this.caseInsensitive || S.caseInsensitive) == 0;
148 if (!(E.AssociatedObjectValue is
string s))
151 return string.Compare(this.value, s, this.caseInsensitive) == 0;
157 if (this.caseInsensitive)
159 if (this.valueLower is
null)
160 this.valueLower = this.value.ToLower();
162 return this.valueLower.GetHashCode();
165 return this.value.GetHashCode();
176 if (DesiredType == typeof(
string))
181 else if (DesiredType == typeof(
char))
183 if (this.value.Length == 1)
185 Value = this.value[0];
194 else if (DesiredType.GetTypeInfo().IsAssignableFrom(typeof(
string).GetTypeInfo()))
199 else if (DesiredType.GetTypeInfo().IsAssignableFrom(typeof(
StringValue).GetTypeInfo()))
Base class for all types of elements.
abstract object AssociatedObjectValue
Associated object value.
virtual bool IsScalar
If the element represents a scalar value.
virtual ICollection< IElement > ChildElements
An enumeration of child elements. If the element is a scalar, this property will return null.
virtual IElement Encapsulate(ICollection< IElement > Elements, ScriptNode Node)
Encapsulates a set of elements into a similar structure as that provided by the current element.
Base class for all types of semigroup elements.
Class managing a script expression.
static bool TryConvert(object Value, Type DesiredType, out object Result)
Tries to convert an object Value to an object of type DesiredType .
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Semi-group of case-insensitive string values.
override ISemiGroupElement AddLeft(ISemiGroupElement Element)
Tries to add an element to the current element, from the left.
override object AssociatedObjectValue
Associated object value.
static readonly StringValue Empty
The empty string.
override bool TryConvertTo(Type DesiredType, out object Value)
Converts the value to a .NET type.
StringValue(string Value)
String value.
string Value
String value.
override bool Equals(object obj)
Compares the element to another. If elements are equal.
bool CaseInsensitive
If the string value is case insensitive or not.
override ISemiGroup AssociatedSemiGroup
Associated Semi-Group.
override string ToString()
override int GetHashCode()
Calculates a hash code of the element. Hash code.
override ISemiGroupElement AddRight(ISemiGroupElement Element)
Tries to add an element to the current element, from the right.
StringValue(string Value, bool CaseInsensitive)
String value.
Semi-group of string values.
Basic interface for all types of elements.
object AssociatedObjectValue
Associated object value.
Basic interface for all types of semigroup elements.
Basic interface for all types of semigroups.