Пример #1
0
        public static NSJSValue ToArray(NSJSVirtualMachine machine, Type element, IList s)
        {
            if (machine == null)
            {
                return(null);
            }
            int       count = s == null ? 0 : s.Count;
            NSJSArray array = null;

            if (element == typeof(byte))
            {
                array = NSJSUInt8Array.New(machine, ToArray <byte>(s));
            }
            else if (element == typeof(sbyte))
            {
                array = NSJSInt8Array.New(machine, ToArray <sbyte>(s));
            }
            else if (element == typeof(short))
            {
                array = NSJSInt16Array.New(machine, ToArray <short>(s));
            }
            else if (element == typeof(ushort))
            {
                array = NSJSUInt16Array.New(machine, ToArray <ushort>(s));
            }
            else if (element == typeof(int))
            {
                array = NSJSInt32Array.New(machine, ToArray <int>(s));
            }
            else if (element == typeof(uint))
            {
                array = NSJSUInt32Array.New(machine, ToArray <uint>(s));
            }
            else if (element == typeof(float))
            {
                array = NSJSFloat32Array.New(machine, ToArray <float>(s));
            }
            else if (element == typeof(double))
            {
                array = NSJSFloat64Array.New(machine, ToArray <double>(s));
            }
            else
            {
                array = NSJSArray.New(machine, count);
                for (int i = 0; i < count; i++)
                {
                    array[i] = ObjectAuxiliary.ToObject(machine, s[i]);
                }
            }
            if (array == null)
            {
                return(NSJSValue.Null(machine));
            }
            return(array);
        }
Пример #2
0
        public static NSJSValue ToArray(NSJSVirtualMachine machine, IEnumerable <IPEndPoint> endpoints)
        {
            if (machine == null)
            {
                return(null);
            }
            int       count = Enumerable.Count(endpoints);
            NSJSArray array = NSJSArray.New(machine, count);
            int       index = 0;

            endpoints.FirstOrDefault(address =>
            {
                array[index++] = ObjectAuxiliary.ToObject(machine, address);
                return(false);
            });
            return(array);
        }
Пример #3
0
        public static NSJSValue ToArray(NSJSVirtualMachine machine, IEnumerable <KeyValuePair <string, string> > s)
        {
            if (machine == null)
            {
                return(null);
            }
            int       count = Enumerable.Count(s);
            NSJSArray array = NSJSArray.New(machine, count);
            int       index = 0;

            s.FirstOrDefault(kv =>
            {
                array[index++] = ObjectAuxiliary.ToObject(machine, kv);
                return(false);
            });
            return(array);
        }
Пример #4
0
        public static NSJSValue ToArray(NSJSVirtualMachine machine, CookieCollection cookies)
        {
            if (machine == null)
            {
                return(null);
            }
            int       count = cookies == null ? 0 : cookies.Count;
            NSJSArray s     = NSJSArray.New(machine, count);

            if (cookies != null)
            {
                int index = 0;
                foreach (Cookie cookie in cookies)
                {
                    s[index++] = ObjectAuxiliary.ToObject(machine, cookie);
                }
            }
            return(s);
        }
Пример #5
0
        public static NSJSValue ToArray(NSJSVirtualMachine machine, IEnumerable <IDbDataParameter> parameters)
        {
            if (machine == null)
            {
                return(null);
            }
            int       count   = parameters.Count();
            NSJSArray results = NSJSArray.New(machine, count);
            int       index   = 0;

            parameters.FirstOrDefault(i =>
            {
                if (i == null)
                {
                    return(false);
                }
                results[index++] = ObjectAuxiliary.ToObject(machine, i);
                return(false);
            });
            return(results);
        }
Пример #6
0
        public static int Fill(NSJSValue source, CookieCollection destination)
        {
            NSJSArray s     = source as NSJSArray;
            int       count = 0;

            if (s == null || destination == null)
            {
                return(count);
            }
            int len = s.Length;

            for (int i = 0; i < len; i++)
            {
                Cookie cookie = ObjectAuxiliary.ToCookie(s[i]);
                if (cookie == null)
                {
                    continue;
                }
                destination.Add(cookie);
                count++;
            }
            return(count);
        }
Пример #7
0
 public static int Fill(NSJSValue source, AttachmentCollection destination)
 {
     return(Fill(source, destination, (s, index) => ObjectAuxiliary.ToAttachment(s[index])));
 }