Пример #1
0
        public static InputVar AddAssignAtRuntime(InputContext context, object o, object v)
        {
            InputVar var = GetVarAtRuntime(context, o, "add-assign");

            if (var.Value is string)
            {
                var.Value = ExStrings.Concat(var.Value, v);
                return(var);
            }
            else if (var.Value is double)
            {
                if (v is double)
                {
                    var.Value = ((double)var.Value) + ((double)v);
                }
                else if (v is int)
                {
                    var.Value = ((double)var.Value) + ((double)((int)v));
                }
                else
                {
                    throw new Exception("Tried to add-assign unsupported type '" + v.GetType() + "' to double var '" + var.Name + "'.");
                }
                return(var);
            }
            else if (var.Value is int)
            {
                if (v is double)
                {
                    var.Value = ((int)var.Value) + ((int)((double)v));
                }
                else if (v is int)
                {
                    var.Value = ((int)var.Value) + ((int)v);
                }
                else
                {
                    throw new Exception("Tried to add-assign unsupported type '" + v.GetType() + "' to int var '" + var.Name + "'.");
                }
                return(var);
            }
            throw new Exception("Tried to add-assign unsupported type '" + var.Value.GetType() + "'.");
        }