Beispiel #1
0
        public JSValue(CefDictionaryValue value)
        {
            if (value == null)
            {
                return;
            }

            var result = new Dictionary <String, Object>();
            var keys   = value.GetKeys();

            for (var i = 0; i < value.Count; i++)
            {
                try
                {
                    switch (value.GetKeyType(keys[i]))
                    {
                    case CefValueType.List:
                        result.Add(keys[i], new JSValue(value.GetList(keys[i])).Value);
                        break;

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

                    case CefValueType.String:
                        result.Add(keys[i], value.GetString(keys[i]));
                        break;

                    case CefValueType.Double:
                        result.Add(keys[i], value.GetDouble(keys[i]));
                        break;

                    case CefValueType.Int:
                        result.Add(keys[i], value.GetInt(keys[i]));
                        break;

                    case CefValueType.Bool:
                        result.Add(keys[i], value.GetBool(keys[i]));
                        break;

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

                    default:
                        result.Add(keys[i], null);
                        break;
                    }
                }
                catch (ArgumentException)
                {
                }
            }

            this.Value = result;
        }
Beispiel #2
0
        static XElement ToXElement(string name, CefDictionaryValue value)
        {
            var result = new XElement(name);
            var keys   = value.GetKeys();

            foreach (var key in keys)
            {
                var type = value.GetValueType(key);
                switch (type)
                {
                case CefValueType.Invalid:
                    break;

                case CefValueType.Null:
                    result.SetAttributeValue(key, null);
                    break;

                case CefValueType.Bool:
                    result.SetAttributeValue(key, value.GetBool(key));
                    break;

                case CefValueType.Int:
                    result.SetAttributeValue(key, value.GetInt(key));
                    break;

                case CefValueType.Double:
                    result.SetAttributeValue(key, value.GetDouble(key));
                    break;

                case CefValueType.String:
                    result.SetAttributeValue(key, value.GetString(key));
                    break;

                case CefValueType.Binary:
                    break;

                case CefValueType.Dictionary:
                    result.Add(ToXElement(key, value.GetDictionary(key)));
                    break;

                case CefValueType.List:
                    result.Add(ToXElement(key, value.GetList(key)));
                    break;

                default:
                    break;
                }
            }
            return(result);
        }