Example #1
0
 private static JSC.JSValue SJ_CustomTypesRepl(JSC.JSValue thisBind, JSC.Arguments args)
 {
     if (args.Length == 2 && args[1].ValueType == JSC.JSValueType.String)
     {
         var s = args[1].Value as string;
         if (s != null)
         {
             if (s.StartsWith("¤BA"))
             {
                 try {
                     return(new ByteArray(Convert.FromBase64String(s.Substring(3))));
                 }
                 catch (Exception ex) {
                     Log.Warning("ParseJson(" + args[0].ToString() + ", " + s + ") - " + ex.Message);
                     return(new ByteArray());
                 }
             }
             // 2015-09-16T14:15:18.994Z
             if (s.Length == 24 && s[4] == '-' && s[7] == '-' && s[10] == 'T' && s[13] == ':' && s[16] == ':' && s[19] == '.')
             {
                 DateTimeOffset dto;
                 if (!DateTimeOffset.TryParseExact(s, "yyyy-MM-ddTH:mm:ss.fffK", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AdjustToUniversal, out dto) ||
                     Math.Abs(dto.Year - 1001) < 1)
                 {
                     return(JSC.JSObject.Marshal(DateTime.Now));
                 }
                 return(JSC.JSValue.Marshal(dto.LocalDateTime));
             }
         }
     }
     return(args[1]);
 }
Example #2
0
        public static void write(Arguments args)
        {
#if PORTABLE
            for (var i = 0; i < args.length; i++)
                System.Diagnostics.Debug.WriteLine(args[0]);
#else
            for (var i = 0; i < args.length; i++)
                System.Diagnostics.Debug.Write(args[0]);
#endif
        }
Example #3
0
        public static void writeln(Arguments args)
        {
            for (var i = 0; i < args.length; i++)
            {
#if !PORTABLE
                if (i < args.length)
                    System.Diagnostics.Debug.Write(args[0]);
                else
#endif
                    System.Diagnostics.Debug.WriteLine(args[args.length - 1]);
            }
        }
Example #4
0
 public static JSObject log(Arguments args)
 {
     for (var i = 0; i < args.length; i++)
     {
         if (i > 0)
             System.Console.Write(" ");
         var r = args[i].ToString();
         System.Console.Write(r);
     }
     System.Console.WriteLine();
     return JSObject.undefined;
 }
Example #5
0
 private static JSC.JSValue ConvertDate(JSC.JSValue thisBind, JSC.Arguments args) {
   if(args.Length == 2 && args[1].ValueType == JSC.JSValueType.String) {
     // 2015-09-16T14:15:18.994Z
     var s = args[1].ToString();
     if(s != null && s.Length == 24 && s[4] == '-' && s[7] == '-' && s[10] == 'T' && s[13] == ':' && s[16] == ':' && s[19] == '.') {
       var a = new JSC.Arguments();
       a.Add(args[1]);
       var jdt = new JSL.Date(a);
       return JSC.JSValue.Wrap(jdt);
     }
   }
   return args[1];
 }
Example #6
0
 public static void assert(Arguments args)
 {
     System.Diagnostics.Debug.Assert((bool)args[0], args[0].ToString());
 }