Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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();
        }