BadScript 2
Loading...
Searching...
No Matches
BadNumber.cs
Go to the documentation of this file.
1using System.Globalization;
2
4
6
10public class BadNumber : BadNative<decimal>, IBadNumber, IComparable, IComparable<BadObject>, IComparable<IBadNumber>
11{
16
21 public BadNumber(decimal value) : base(value) { }
22
23#region IBadNumber Members
24
26 decimal IBadNumber.Value => Value;
27
28#endregion
29
30#region IComparable Members
31
38 public int CompareTo(object obj)
39 {
40 if (obj is BadObject o)
41 {
42 return CompareTo(o);
43 }
44
45 throw new Exception("Cannot compare number to non number");
46 }
47
48#endregion
49
50#region IComparable<BadObject> Members
51
58 public int CompareTo(BadObject other)
59 {
60 if (other is IBadNumber num)
61 {
62 return CompareTo(num);
63 }
64
65 throw new Exception("Cannot compare number to non number");
66 }
67
68#endregion
69
70#region IComparable<IBadNumber> Members
71
77 public int CompareTo(IBadNumber other)
78 {
79 return Value.CompareTo(other.Value);
80 }
81
82#endregion
83
86 {
87 return s_Prototype;
88 }
89
91 public override string ToSafeString(List<BadObject> done)
92 {
93 return Value.ToString(CultureInfo.InvariantCulture);
94 }
95}
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
BadNumber(decimal value)
Creates a new Native Number.
Definition BadNumber.cs:21
static readonly BadClassPrototype s_Prototype
The Prototype for the Native Number Object.
Definition BadNumber.cs:15
int CompareTo(BadObject other)
Compares this Number to another Number.
Definition BadNumber.cs:58
override BadClassPrototype GetPrototype()
Definition BadNumber.cs:85
override string ToSafeString(List< BadObject > done)
Definition BadNumber.cs:91
decimal IBadNumber. Value
The Number Value.
Definition BadNumber.cs:26
int CompareTo(IBadNumber other)
Compares this Number to another Number.
Definition BadNumber.cs:77
int CompareTo(object obj)
Compares this Number to another Number.
Definition BadNumber.cs:38
Implements a Class Prototype for the BadScript Language.
Helper Class that Builds a Native Class from a Prototype.
static BadClassPrototype GetNative(string name)
Returns a Native Class Prototype for the given Native Type.
Implements the Interface for Native Numbers.
Definition IBadNumber.cs:7
new decimal Value
The Number Value.
Definition IBadNumber.cs:11
Contains the Native Runtime Objects.
Definition BadBoolean.cs:6