/// <summary> /// Used by the JSON.stringify to transform objects prior to serialization. /// </summary> /// <param name="thisObj"> The object that is being operated on. </param> /// <param name="key"> Unused. </param> /// <returns> The date as a serializable string. </returns> public static object ToJSON(ObjectInstance thisObj, string key) { var number = TypeConverter.ToPrimitive(thisObj, PrimitiveTypeHint.Number); if (number is double && (double.IsInfinity((double)number) || double.IsNaN((double)number))) { return(Null.Value); } return(thisObj.CallMemberFunction("toISOString")); }
public object Decode(object a, ObjectInstance b) { if (b is Hashlink) { return(((Hashlink)b).Decode(a)); } else if (b.Prototype is Hashlink) { return(b.CallMemberFunction("decode", a)); } return(null); }
public string Encode(ObjectInstance a) { if (a is Hashlink) { return(((Hashlink)a).Encode()); } else if (a.Prototype is Hashlink) { return(TypeConverter.ConvertTo <string>(Engine, a.CallMemberFunction("encode", a))); } return(string.Empty); }