2using System.Collections.Generic;
 
    4using System.Threading.Tasks;
 
   22            Type xType = x.GetType();
 
   23            Type yType = y.GetType();
 
   27                if (x is DateTime TPx && 
 
   29                    TPx.Kind != TPy.Kind && 
 
   30                    TPx.Kind != DateTimeKind.Unspecified &&
 
   31                    TPy.Kind != DateTimeKind.Unspecified)
 
   33                    x = TPx.ToLocalTime();
 
   34                    y = TPy.ToLocalTime();
 
   43            Upgrade(ref x, ref xTypeCode);
 
   44            Upgrade(ref y, ref yTypeCode);
 
   46            if (xTypeCode == yTypeCode)
 
   61                x = ToString(x, xTypeCode);
 
   70                        y = (decimal)((
double)y);
 
   79                        x = (decimal)((
double)x);
 
   86                    y = ToString(y, yTypeCode);
 
   94        internal static string ToString(
object Value)
 
  102        internal static string ToString(
object Value, uint TypeCode)
 
  107                return Value.ToString().Replace(System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator, 
".");
 
  109                return ((DateTime)Value).ToUniversalTime().ToString(
"yyyy-MM-ddTHH:mm:ss") + 
"z";
 
  111                return ((DateTimeOffset)Value).ToUniversalTime().DateTime.ToString(
"yyyy-MM-ddTHH:mm:ss") + 
"z";
 
  113                return Convert.ToBase64String((
byte[])Value);
 
  115                return Value?.ToString() ?? 
string.Empty;
 
  118        private static void Upgrade(ref 
object Value, ref uint TypeCode)
 
  123                    Value = (decimal)(((
bool)Value) ? 1 : 0);
 
  128                    Value = (decimal)((
byte)Value);
 
  134                    Value = (decimal)((
short)Value);
 
  140                    Value = (decimal)((
int)Value);
 
  146                    Value = (decimal)((
long)Value);
 
  151                    Value = (decimal)((sbyte)Value);
 
  157                    Value = (decimal)((ushort)Value);
 
  163                    Value = (decimal)((uint)Value);
 
  169                    Value = (decimal)((ulong)Value);
 
  180                    Value = (double)((
float)Value);
 
  185                    Value = ((DateTime)Value).ToUniversalTime();
 
  189                    Value = ((DateTimeOffset)Value).ToUniversalTime().DateTime;
 
  196                    Value = (decimal)((
char)Value);
 
  206                    Value = Value.ToString();
 
  222        public static int? 
Compare(
object Value1, 
object Value2)
 
  224            bool IsNull1 = Value1 is 
null;
 
  225            bool IsNull2 = Value2 is 
null;
 
  227            if (IsNull1 ^ IsNull2)
 
  240            if (Value1 is IComparable Comparable)
 
  241                return Comparable.CompareTo(Value2);
 
  242            else if (Value1 is 
byte[] b1 && Value2 is 
byte[] b2)
 
  243                return Storage.IndexRecords.BinaryCompare(b1, b2);
 
  258            Type T = Value.GetType();
 
  272                    byte b = (byte)Value;
 
  273                    if (b == 
byte.MaxValue)
 
  274                        Value = (ushort)(
byte.MaxValue + 1);
 
  284                    short i16 = (short)Value;
 
  285                    if (i16 == 
short.MaxValue)
 
  286                        Value = short.MaxValue + 1;
 
  296                    int i32 = (int)Value;
 
  297                    if (i32 == 
int.MaxValue)
 
  298                        Value = (long)
int.MaxValue + 1;
 
  308                    long i64 = (long)Value;
 
  309                    if (i64 == 
long.MaxValue)
 
  310                        Value = (ulong)
long.MaxValue + 1;
 
  319                    sbyte i8 = (sbyte)Value;
 
  320                    if (i8 == sbyte.MaxValue)
 
  321                        Value = (short)sbyte.MaxValue + 1;
 
  331                    ushort ui16 = (ushort)Value;
 
  332                    if (ui16 == ushort.MaxValue)
 
  333                        Value = (uint)ushort.MaxValue + 1;
 
  343                    uint ui32 = (uint)Value;
 
  344                    if (ui32 == uint.MaxValue)
 
  345                        Value = (ulong)uint.MaxValue + 1;
 
  355                    ulong ui64 = (ulong)Value;
 
  356                    if (ui64 == ulong.MaxValue)
 
  358                        double d = ulong.MaxValue;
 
  359                        if (Increment(ref d))
 
  375                    decimal dec = (decimal)Value;
 
  376                    if (!Increment(ref dec))
 
  385                    double dbl = (double)Value;
 
  386                    if (!Increment(ref dbl))
 
  395                    float sng = (float)Value;
 
  396                    if (!Increment(ref sng))
 
  405                    DateTime DT = (DateTime)Value;
 
  406                    if (DT.Ticks == 
long.MaxValue)
 
  410                        Value = 
new DateTime(DT.Ticks + 1, DT.Kind);
 
  415                    DateTimeOffset DTO = (DateTimeOffset)Value;
 
  416                    if (DTO.Ticks == 
long.MaxValue)
 
  420                        Value = 
new DateTimeOffset(DTO.Ticks + 1, DTO.Offset);
 
  425                    TimeSpan TS = (TimeSpan)Value;
 
  426                    if (TS.Ticks == 
long.MaxValue)
 
  430                        Value = 
new TimeSpan(TS.Ticks + 1);
 
  435                    char ch = (char)Value;
 
  436                    if (ch == 
char.MaxValue)
 
  437                        Value = char.MaxValue + 1;
 
  439                        Value = (char)(ch + 1);
 
  443                    string s = (string)Value;
 
  444                    if (Increment(ref s))
 
  455                    if (Increment(ref s))
 
  464                    s = Value.ToString();
 
  465                    if (Increment(ref s))
 
  474                    Guid Guid = (Guid)Value;
 
  475                    if (Increment(ref Guid))
 
  484                    byte[] Bin = (
byte[])((
byte[])Value).Clone();
 
  513                Value = 
double.Epsilon;
 
  517            double Eps = Value / Math.Pow(2, 51);
 
  521            while (Value != (Diff = (Value + Eps)))
 
  545                Value = 
float.Epsilon;
 
  549            float Eps = Value / (float)Math.Pow(2, 21);
 
  553            while (Value != (Diff = (Value + Eps)))
 
  577                Value = DecimalEpsilon;
 
  581            decimal Eps = Value / (decimal)Math.Pow(2, 92);
 
  583            decimal Last = Value;
 
  585            while (Value != (Diff = (Value + Eps)))
 
  603        public static readonly decimal DecimalEpsilon = 
new decimal(1, 0, 0, 
false, 28);
 
  623            string s = Value.Value;
 
  636            byte[] A = Value.ToByteArray();
 
  716            Type T = Value.GetType();
 
  730                    byte b = (byte)Value;
 
  731                    if (b == 
byte.MinValue)
 
  742                    short i16 = (short)Value;
 
  743                    if (i16 == 
short.MinValue)
 
  744                        Value = short.MinValue - 1;
 
  754                    int i32 = (int)Value;
 
  755                    if (i32 == 
int.MinValue)
 
  756                        Value = (long)
int.MinValue - 1;
 
  766                    long i64 = (long)Value;
 
  767                    if (i64 == 
long.MinValue)
 
  769                        double d = 
long.MinValue;
 
  770                        if (Decrement(ref d))
 
  786                    sbyte i8 = (sbyte)Value;
 
  787                    if (i8 == sbyte.MinValue)
 
  788                        Value = (short)sbyte.MinValue - 1;
 
  798                    ushort ui16 = (ushort)Value;
 
  799                    if (ui16 == ushort.MinValue)
 
  800                        Value = (short)ushort.MinValue - 1;
 
  810                    uint ui32 = (uint)Value;
 
  811                    if (ui32 == uint.MinValue)
 
  812                        Value = (int)uint.MinValue - 1;
 
  822                    ulong ui64 = (ulong)Value;
 
  823                    if (ui64 == ulong.MinValue)
 
  824                        Value = (long)ulong.MinValue - 1;
 
  833                    decimal dec = (decimal)Value;
 
  834                    if (!Decrement(ref dec))
 
  843                    double dbl = (double)Value;
 
  844                    if (!Decrement(ref dbl))
 
  853                    float sng = (float)Value;
 
  854                    if (!Decrement(ref sng))
 
  863                    DateTime DT = (DateTime)Value;
 
  864                    if (DT.Ticks == 
long.MinValue)
 
  868                        Value = 
new DateTime(DT.Ticks - 1, DT.Kind);
 
  873                    DateTimeOffset DTO = (DateTimeOffset)Value;
 
  874                    if (DTO.Ticks == 
long.MinValue)
 
  878                        Value = 
new DateTimeOffset(DTO.Ticks - 1, DTO.Offset);
 
  883                    TimeSpan TS = (TimeSpan)Value;
 
  884                    if (TS.Ticks == 
long.MinValue)
 
  888                        Value = 
new TimeSpan(TS.Ticks - 1);
 
  893                    char ch = (char)Value;
 
  894                    if (ch == 
char.MinValue)
 
  895                        Value = char.MinValue - 1;
 
  897                        Value = (char)(ch - 1);
 
  902                    string s = (string)Value;
 
  903                    if (Decrement(ref s))
 
  914                    if (Decrement(ref s))
 
  923                    s = Value.ToString();
 
  924                    if (Decrement(ref s))
 
  933                    Guid Guid = (Guid)Value;
 
  934                    if (!Decrement(ref Guid))
 
  943                    byte[] Bin = (
byte[])((
byte[])Value).Clone();
 
  972                Value = -
double.Epsilon;
 
  976            double Eps = Value / Math.Pow(2, 51);
 
  980            while (Value != (Diff = (Value + Eps)))
 
 1004                Value = -
float.Epsilon;
 
 1008            float Eps = Value / (float)Math.Pow(2, 21);
 
 1012            while (Value != (Diff = (Value + Eps)))
 
 1036                Value = -DecimalEpsilon;
 
 1040            decimal Eps = Value / (decimal)Math.Pow(2, 92);
 
 1042            decimal Last = Value;
 
 1044            while (Value != (Diff = (Value + Eps)))
 
 1066            if (
string.IsNullOrEmpty(Value))
 
 1069            int c = Value.Length;
 
 1070            char ch = Value[c - 1];
 
 1073                Value = Value.Substring(0, c - 1);
 
 1075                Value = Value.Substring(0, c - 1) + ((char)(ch - 1)) + 
char.MaxValue;
 
 1087            string s = Value.Value;
 
 1088            if (!Decrement(ref s))
 
 1102            byte[] A = Value.ToByteArray();
 
 1168            Value = 
new Guid(A);
 
Represents a case-insensitive string.
string Value
String-representation of the case-insensitive string. (Representation is case sensitive....
Static class that performs comparisons of property values.
static bool Decrement(ref object Value)
Decrements Value  to the largest value smaller than Value .
static bool Decrement(ref CaseInsensitiveString Value)
Decrements Value  to the largest value smaller than Value .
static bool Decrement(ref float Value)
Decrements Value  to the largest value smaller than Value .
static ? int Compare(object Value1, object Value2)
Compares two values. The values can be of different, but compatible types.
static bool Increment(ref CaseInsensitiveString Value)
Increments Value  to the smallest value greater than Value .
static bool Increment(ref string Value)
Increments Value  to the smallest value greater than Value .
static bool Decrement(ref Guid Value)
Decrements Value  to the largest value smaller than Value .
static bool Decrement(ref double Value)
Decrements Value  to the largest value smaller than Value .
static bool TryMakeSameType(ref object x, ref object y)
Tries to make sure x  and y  have the same type.
static bool Increment(ref object Value)
Increments Value  to the smallest value greater than Value .
static bool Increment(ref float Value)
Increments Value  to the smallest value greater than Value .
static bool Decrement(ref decimal Value)
Decrements Value  to the largest value smaller than Value .
static bool Increment(ref Guid Value)
Increments Value  to the smallest value greater than Value .
static bool Decrement(ref string Value)
Decrements Value  to the largest value smaller than Value .
static bool Increment(ref double Value)
Increments Value  to the smallest value greater than Value .
static bool Increment(ref decimal Value)
Increments Value  to the smallest value greater than Value .
Serializes a class, taking into account attributes defined in Attributes.
const uint TYPE_DECIMAL
Represents a Decimal
const uint TYPE_TIMESPAN
Represents a TimeSpan
const uint TYPE_UINT64
Represents a UInt64
const uint TYPE_NULL
Represents a null value.
const uint TYPE_SBYTE
Represents a SByte
const uint TYPE_VARINT64
Variable length INT64
const uint TYPE_INT64
Represents a Int64
const uint TYPE_BOOLEAN
Represents a Boolean
const uint TYPE_BYTE
Represents a Byte
const uint TYPE_CHAR
Represents a Char
const uint TYPE_VARUINT32
Variable length UINT32
const uint TYPE_VARINT16
Variable length INT16
const uint TYPE_STRING
Represents a String
static uint GetFieldDataTypeCode(object Value)
Returns the type code corresponding to a given field data type.
const uint TYPE_UINT16
Represents a UInt16
const uint TYPE_CI_STRING
Represents a CaseInsensitiveString
const uint TYPE_SINGLE
Represents a Single
const uint TYPE_DATETIMEOFFSET
Represents a DateTimeOffset
const uint TYPE_VARUINT16
Variable length UINT16
const uint TYPE_BYTEARRAY
Represents a byte array.
const uint TYPE_VARUINT64
Variable length UINT64
const uint TYPE_INT32
Represents a Int32
const uint TYPE_UINT32
Represents a UInt32
const uint TYPE_DATETIME
Represents a DateTime
const uint TYPE_VARINT32
Variable length INT32
const uint TYPE_GUID
Represents a Guid
const uint TYPE_ENUM
Represents an enumerated value.
const uint TYPE_DOUBLE
Represents a Double
const uint TYPE_INT16
Represents a Int16