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
25 decimal IBadNumber.Value => Value;
26
33 public int CompareTo(object obj)
34 {
35 if (obj is BadObject o)
36 {
37 return CompareTo(o);
38 }
39
40 throw new Exception("Cannot compare number to non number");
41 }
42
49 public int CompareTo(BadObject other)
50 {
51 if (other is IBadNumber num)
52 {
53 return CompareTo(num);
54 }
55
56 throw new Exception("Cannot compare number to non number");
57 }
58
64 public int CompareTo(IBadNumber other)
65 {
66 return Value.CompareTo(other.Value);
67 }
68
71 {
72 return s_Prototype;
73 }
74
76 public override string ToSafeString(List<BadObject> done)
77 {
78 return Value.ToString(CultureInfo.InvariantCulture);
79 }
80}
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:49
override BadClassPrototype GetPrototype()
Definition BadNumber.cs:70
override string ToSafeString(List< BadObject > done)
Definition BadNumber.cs:76
decimal IBadNumber. Value
The Number Value.
Definition BadNumber.cs:25
int CompareTo(IBadNumber other)
Compares this Number to another Number.
Definition BadNumber.cs:64
int CompareTo(object obj)
Compares this Number to another Number.
Definition BadNumber.cs:33
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