internal virtual object GetDefaultValue(Type hint, bool avoid_toString) { if (avoid_toString) { return(this); } else { return(ObjectPrototype.smartToString(this)); } }
public static string ToString(object value, bool explicitOK) { IConvertible ic = value as IConvertible; TypeCode tc = Convert.GetTypeCode(value, ic); switch (tc) { case TypeCode.Empty: return("undefined"); case TypeCode.DBNull: return("null"); case TypeCode.Boolean: bool r = (bool)value; if (r) { return("true"); } else { return("false"); } case TypeCode.Char: return(ic.ToInt16(null).ToString()); case TypeCode.String: return(ic.ToString(null)); case TypeCode.Object: if (value is StringObject) { return(((StringObject)value).value); } else if (value is ScriptObject) { ScriptObject obj_value = (ScriptObject)value; if (obj_value.HasMethod("toString")) { return((string)obj_value.CallMethod("toString")); } else { return((string)ObjectPrototype.smartToString((JSObject)obj_value)); } } Console.WriteLine("value.GetType = {0}", value.GetType()); throw new NotImplementedException(); default: if (IsNumberTypeCode(tc)) { double val = ic.ToDouble(null); return(ToString(val)); } Console.WriteLine("tc = {0}", tc); throw new NotImplementedException(); } }