Skip to content

Commit

Permalink
Double datatype changes (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosga authored Jun 9, 2024
1 parent e29e96b commit 3a9e38f
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 138 deletions.
76 changes: 45 additions & 31 deletions src/facturae/DataType/DoubleFourDecimalType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,55 +45,69 @@ public static DoubleFourDecimalType Parse(string value)

public static bool operator ==(DoubleFourDecimalType left, DoubleFourDecimalType right)
{
return left.Value == right.Value;
return left._value == right._value;
}

public static bool operator !=(DoubleFourDecimalType left, DoubleFourDecimalType right)
{
return left.Value != right.Value;
return left._value != right._value;
}

public static bool operator >(DoubleFourDecimalType left, DoubleFourDecimalType right)
{
return left.Value > right.Value;
return left._value > right._value;
}

public static bool operator >=(DoubleFourDecimalType left, DoubleFourDecimalType right)
{
return left.Value >= right.Value;
return left._value >= right._value;
}

public static bool operator <(DoubleFourDecimalType left, DoubleFourDecimalType right)
{
return left.Value < right.Value;
return left._value < right._value;
}

public static bool operator <=(DoubleFourDecimalType left, DoubleFourDecimalType right)
{
return left.Value <= right.Value;
return left._value <= right._value;
}

public static implicit operator decimal(DoubleFourDecimalType x)
{
return x.Value;
return x._value;
}

public static implicit operator DoubleFourDecimalType(decimal x)
{
return new DoubleFourDecimalType(x);
}

[XmlIgnore]
public decimal Value { get; private set; }
public static implicit operator DoubleFourDecimalType(DoubleTwoDecimalType x)
{
return new DoubleFourDecimalType((decimal)x);
}

public static implicit operator DoubleFourDecimalType(DoubleSixDecimalType x)
{
return new DoubleFourDecimalType((decimal)x);
}

public static implicit operator DoubleFourDecimalType(DoubleUpToEightDecimalType x)
{
return new DoubleFourDecimalType((decimal)x);
}

private decimal _value;

public DoubleFourDecimalType(decimal value)
{
Value = value;
_value = value;
}

public override readonly int GetHashCode()
{
return 207501131 ^ Value.GetHashCode();
return 207501131 ^ _value.GetHashCode();
}

public override readonly bool Equals(object obj)
Expand All @@ -103,22 +117,22 @@ public override readonly bool Equals(object obj)

public override readonly string ToString()
{
return Value.ToString("F4", System.Globalization.CultureInfo.InvariantCulture);
return _value.ToString("F4", System.Globalization.CultureInfo.InvariantCulture);
}

public readonly string ToString(string format)
{
return Value.ToString(format);
return _value.ToString(format);
}

public readonly int CompareTo(object obj)
{
return Value.CompareTo(obj);
return _value.CompareTo(obj);
}

public readonly string ToString(string format, IFormatProvider formatProvider)
{
return Value.ToString("F4", formatProvider);
return _value.ToString("F4", formatProvider);
}

readonly TypeCode IConvertible.GetTypeCode()
Expand All @@ -128,57 +142,57 @@ readonly TypeCode IConvertible.GetTypeCode()

readonly bool IConvertible.ToBoolean(IFormatProvider provider)
{
return Convert.ToBoolean(Value);
return Convert.ToBoolean(_value);
}

readonly byte IConvertible.ToByte(IFormatProvider provider)
{
return Convert.ToByte(Value);
return Convert.ToByte(_value);
}

readonly char IConvertible.ToChar(IFormatProvider provider)
{
return Convert.ToChar(Value);
return Convert.ToChar(_value);
}

readonly DateTime IConvertible.ToDateTime(IFormatProvider provider)
{
return Convert.ToDateTime(Value);
return Convert.ToDateTime(_value);
}

readonly decimal IConvertible.ToDecimal(IFormatProvider provider)
{
return Value;
return _value;
}

readonly double IConvertible.ToDouble(IFormatProvider provider)
{
return Convert.ToDouble(Value);
return Convert.ToDouble(_value);
}

readonly short IConvertible.ToInt16(IFormatProvider provider)
{
return Convert.ToInt16(Value);
return Convert.ToInt16(_value);
}

readonly int IConvertible.ToInt32(IFormatProvider provider)
{
return Convert.ToInt32(Value);
return Convert.ToInt32(_value);
}

readonly long IConvertible.ToInt64(IFormatProvider provider)
{
return Convert.ToInt64(Value);
return Convert.ToInt64(_value);
}

readonly sbyte IConvertible.ToSByte(IFormatProvider provider)
{
return Convert.ToSByte(Value);
return Convert.ToSByte(_value);
}

readonly float IConvertible.ToSingle(IFormatProvider provider)
{
return Convert.ToSingle(Value);
return Convert.ToSingle(_value);
}

readonly string IConvertible.ToString(IFormatProvider provider)
Expand All @@ -188,22 +202,22 @@ readonly string IConvertible.ToString(IFormatProvider provider)

readonly object IConvertible.ToType(Type conversionType, IFormatProvider provider)
{
return Convert.ChangeType(Value, conversionType);
return Convert.ChangeType(_value, conversionType);
}

readonly ushort IConvertible.ToUInt16(IFormatProvider provider)
{
return Convert.ToUInt16(Value);
return Convert.ToUInt16(_value);
}

readonly uint IConvertible.ToUInt32(IFormatProvider provider)
{
return Convert.ToUInt32(Value);
return Convert.ToUInt32(_value);
}

readonly ulong IConvertible.ToUInt64(IFormatProvider provider)
{
return Convert.ToUInt64(Value);
return Convert.ToUInt64(_value);
}

readonly int IComparable<decimal>.CompareTo(decimal other)
Expand All @@ -225,7 +239,7 @@ public void ReadXml(XmlReader reader)
{
if (reader is not null)
{
Value = reader.ReadElementContentAsDecimal();
_value = reader.ReadElementContentAsDecimal();
}
}

Expand Down
Loading

0 comments on commit 3a9e38f

Please sign in to comment.