44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using System;
|
|
|
|
namespace AnotherReplayReader.Apm
|
|
{
|
|
internal class DataValue : IComparable<DataValue>, IComparable
|
|
{
|
|
public int? NumberValue { get; }
|
|
public string Value { get; }
|
|
|
|
public DataValue(string value)
|
|
{
|
|
Value = value;
|
|
if (int.TryParse(value, out var numberValue))
|
|
{
|
|
NumberValue = numberValue;
|
|
}
|
|
}
|
|
|
|
public override string ToString() => Value;
|
|
|
|
public int CompareTo(DataValue other)
|
|
{
|
|
if (NumberValue.HasValue == other.NumberValue.HasValue)
|
|
{
|
|
if (!NumberValue.HasValue)
|
|
{
|
|
return Value.CompareTo(other.Value);
|
|
}
|
|
return NumberValue.Value.CompareTo(other.NumberValue!.Value);
|
|
}
|
|
return NumberValue.HasValue ? 1 : -1;
|
|
}
|
|
|
|
public int CompareTo(object obj)
|
|
{
|
|
if (obj is DataValue other)
|
|
{
|
|
return CompareTo(other);
|
|
}
|
|
throw new NotSupportedException();
|
|
}
|
|
}
|
|
}
|