Пример #1
0
        public static List <dynamic> ConvertToV8List(CefListValue arguments)
        {
            var args = new List <dynamic>();

            if (arguments != null)
            {
                for (var i = 0; i < arguments.Count; i++)
                {
                    var    type = arguments.GetValueType(i);
                    object value;
                    switch (type)
                    {
                    case CefValueType.Null: value = null; break;

                    case CefValueType.String: value = arguments.GetString(i); break;

                    case CefValueType.Int: value = arguments.GetInt(i); break;

                    case CefValueType.Double: value = arguments.GetDouble(i); break;

                    case CefValueType.Bool: value = arguments.GetBool(i); break;

                    default: value = null; break;
                    }
                    if (value != null)
                    {
                        args.Add(value);
                    }
                }
            }
            return(args);
        }
Пример #2
0
        static XElement ToXElement(string name, CefListValue value)
        {
            var result = new XElement(name);
            var count  = value.Count;

            for (int i = 0; i < count; i++)
            {
                var type = value.GetValueType(i);
                switch (type)
                {
                case CefValueType.Invalid:
                    break;

                case CefValueType.Null:
                    result.Add(new XElement("item", null));
                    break;

                case CefValueType.Bool:
                    result.Add(new XElement("item", value.GetBool(i)));
                    break;

                case CefValueType.Int:
                    result.Add(new XElement("item", value.GetInt(i)));
                    break;

                case CefValueType.Double:
                    result.Add(new XElement("item", value.GetDouble(i)));
                    break;

                case CefValueType.String:
                    result.Add(new XElement("item", value.GetString(i)));
                    break;

                case CefValueType.Binary:
                    break;

                case CefValueType.Dictionary:
                    result.Add(ToXElement("item", value.GetDictionary(i)));
                    break;

                case CefValueType.List:
                    result.Add(ToXElement("item", value.GetList(i)));
                    break;

                default:
                    break;
                }
            }
            return(result);
        }
Пример #3
0
        public JSValue(CefListValue value)
        {
            if (value == null)
            {
                return;
            }

            var result = new List <Object>();

            for (var i = 0; i < value.Count; i++)
            {
                switch (value.GetValueType(i))
                {
                case CefValueType.List:
                    result.Add(new JSValue(value.GetList(i)).Value);
                    break;

                case CefValueType.Binary:
                    result.Add(new JSValue(value.GetBinary(i)).Value);
                    break;

                case CefValueType.String:
                    result.Add(value.GetString(i));
                    break;

                case CefValueType.Double:
                    result.Add(value.GetDouble(i));
                    break;

                case CefValueType.Int:
                    result.Add(value.GetInt(i));
                    break;

                case CefValueType.Bool:
                    result.Add(value.GetBool(i));
                    break;

                case CefValueType.Dictionary:
                    result.Add(new JSValue(value.GetDictionary(i)).Value);
                    break;

                default:
                    result.Add(null);
                    break;
                }
            }

            this.Value = result.ToArray();
        }