Example #1
0
        public override ISCType Subtract(ISCType obj)
        {
            if (obj.IsOfType <SC_Int, SC_Long>())
            {
                return(new SC_Long(value - obj.GetValueAs <long>()));
            }

            throw new ArgumentException($"you cant subtract {obj.GetType()} to a long");
        }
Example #2
0
        public override ISCType Multiply(ISCType obj)
        {
            if (obj.IsOfType <SC_Int, SC_Long>())
            {
                return(new SC_Long(value * obj.GetValueAs <long>()));
            }

            throw new ArgumentException($"you cant multiply {obj.GetType()} to a long");
        }
Example #3
0
 public static void AddToRegister(this Dictionary <string, ISCType> register, string name, ISCType obj)
 {
     if (register.ContainsKey(name))
     {
         register[name] = obj;
     }
     else
     {
         register.Add(name, obj);
     }
 }
Example #4
0
        public override ISCType Add(ISCType obj)
        {
            if (obj.IsOfType <SC_Int>())
            {
                return(new SC_Int(value + obj.GetValueAs <int>()));
            }

            if (obj.IsOfType <SC_Long>())
            {
                return(new SC_Long(value + obj.GetValueAs <long>()));
            }

            return(new SC_String(value.ToString() + obj.GetValueAs <string>()));
        }
Example #5
0
        public override ISCType Multiply(ISCType obj)
        {
            if (obj.IsOfType <SC_Int>())
            {
                return(new SC_Long(value * obj.GetValueAs <int>()));
            }

            if (obj.IsOfType <SC_Long>())
            {
                return(new SC_Long(value * obj.GetValueAs <long>()));
            }

            throw new ArgumentException("Sorry you cant multiply a string with an int");
        }
Example #6
0
        public override ISCType Add(ISCType obj)
        {
            if (obj.IsOfType <SC_Int, SC_Long>())
            {
                return(new SC_Long(value + obj.GetValueAs <long>()));
            }

            if (obj.IsOfType <SC_String>())
            {
                return(new SC_String(value + obj.GetValueAs <string>()));
            }

            throw new ArgumentException($"you cant add {obj.GetType()} to a long");
        }
        public override ISCType Multiply(ISCType obj)
        {
            if (obj.IsOfType <SC_Int, SC_Long>())
            {
                string s = "";

                for (int i = 0; i < obj.GetValueAs <int>(); i++)
                {
                    s += value;
                }

                return(new SC_String(s));
            }

            throw new ArgumentException("You cant multiply two strings together!");
        }
Example #8
0
 public static bool IsOfType <T>(this ISCType obj) where T : ISCType
 {
     return(obj.GetType() == typeof(T));
 }
 public override ISCType Subtract(ISCType obj)
 {
     throw new NotSupportedException("You cant subtract from a string!");
 }
Example #10
0
 public abstract ISCType Add(ISCType obj);
Example #11
0
 public override ISCType Divide(ISCType obj)
 {
     throw new ArgumentException("Sorry this may never be supported!");
 }
 public override bool IsLower(ISCType obj)
 {
     throw new NotSupportedException("You cant use islower on a string");
 }
Example #13
0
 public abstract ISCType Multiply(ISCType obj);
Example #14
0
 public abstract ISCType Subtract(ISCType obj);
 public override bool IsEqual(ISCType obj)
 {
     return(obj.IsOfType <SC_String>() && obj.GetValueAs <string>().Equals(value));
 }
Example #16
0
 public override bool IsEqual(ISCType obj)
 {
     return(obj.IsOfType <SC_Long, SC_Int>() && obj.GetValueAs <long>() == value);
 }
Example #17
0
 public abstract ISCType Divide(ISCType obj);
 public override ISCType Add(ISCType obj)
 {
     return(new SC_String(value + obj.GetValueAs <string>()));
 }
Example #19
0
 public abstract bool IsLower(ISCType obj);
Example #20
0
 public abstract bool IsEqual(ISCType obj);
Example #21
0
 public override ISCType Divide(ISCType obj)
 {
     throw new NotImplementedException();
 }
 public override ISCType Divide(ISCType obj)
 {
     throw new NotSupportedException("You cant divide from a string!");
 }
Example #23
0
 public override bool IsLower(ISCType obj)
 {
     return(obj.IsOfType <SC_Int, SC_Long>() && value < obj.GetValueAs <long>());
 }
Example #24
0
 public static bool IsOfType <T1, T2>(this ISCType obj) where T1 : ISCType where T2 : ISCType
 {
     return(obj.GetType() == typeof(T1) || obj.GetType() == typeof(T2));
 }