/// <summary>
        /// Sets the value at the specified key. Returns true if the value was set
        /// successfully. If |value| represents simple data then the underlying data
        /// will be copied and modifications to |value| will not modify this object. If
        /// |value| represents complex data (binary, dictionary or list) then the
        /// underlying data will be referenced and modifications to |value| will modify
        /// this object.
        /// </summary>
        public bool SetValue(string key, CefValue value)
        {
            fixed(char *key_str = key)
            {
                var n_key   = new cef_string_t(key_str, key != null ? key.Length : 0);
                var n_value = value.ToNative();

                return(cef_dictionary_value_t.set_value(_self, &n_key, n_value) != 0);
            }
        }
예제 #2
0
        /// <summary>
        /// Generates a JSON string from the specified root |node| which should be a
        /// dictionary or list value. Returns an empty string on failure. This method
        /// requires exclusive access to |node| including any underlying data.
        /// </summary>
        public static string WriteJson(CefValue value, CefJsonWriterOptions options)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            var n_result = libcef.write_json(value.ToNative(), options);

            return(cef_string_userfree.ToString(n_result));
        }
예제 #3
0
        /// <summary>
        /// Parses the specified |json_string| and returns a dictionary or list
        /// representation. If JSON parsing fails this method returns NULL.
        /// </summary>
        public static CefValue ParseJson(string value, CefJsonParserOptions options)
        {
            fixed(char *value_str = value)
            {
                var n_value  = new cef_string_t(value_str, value != null ? value.Length : 0);
                var n_result = libcef.parse_json(&n_value, options);

                return(CefValue.FromNativeOrNull(n_result));
            }
        }
예제 #4
0
        /// <summary>
        /// Returns the value for the preference with the specified |name|. Returns
        /// NULL if the preference does not exist. The returned object contains a copy
        /// of the underlying preference value and modifications to the returned object
        /// will not modify the underlying preference value. This method must be called
        /// on the browser process UI thread.
        /// </summary>
        public CefValue GetPreference(string name)
        {
            fixed(char *name_str = name)
            {
                var n_name  = new cef_string_t(name_str, name != null ? name.Length : 0);
                var n_value = cef_request_context_t.get_preference(_self, &n_name);

                return(CefValue.FromNativeOrNull(n_value));
            }
        }
        /// <summary>
        /// Returns the value at the specified key. For simple types the returned
        /// value will copy existing data and modifications to the value will not
        /// modify this object. For complex types (binary, dictionary and list) the
        /// returned value will reference existing data and modifications to the value
        /// will modify this object.
        /// </summary>
        public CefValue GetValue(string key)
        {
            fixed(char *key_str = key)
            {
                var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);

                var n_result = cef_dictionary_value_t.get_value(_self, &n_key);

                return(CefValue.FromNativeOrNull(n_result));
            }
        }
예제 #6
0
        /// <summary>
        /// Set the |value| associated with preference |name|. Returns true if the
        /// value is set successfully and false otherwise. If |value| is NULL the
        /// preference will be restored to its default value. If setting the preference
        /// fails then |error| will be populated with a detailed description of the
        /// problem. This method must be called on the browser process UI thread.
        /// </summary>
        public bool SetPreference(string name, CefValue value, out string error)
        {
            fixed(char *name_str = name)
            {
                var n_name  = new cef_string_t(name_str, name != null ? name.Length : 0);
                var n_value = value != null?value.ToNative() : null;

                cef_string_t n_error;

                var n_result = cef_request_context_t.set_preference(_self, &n_name, n_value, &n_error);

                error = cef_string_t.ToString(&n_error);
                return(n_result != 0);
            }
        }
예제 #7
0
        /// <summary>
        /// Parses the specified |json_string| and returns a dictionary or list
        /// representation. If JSON parsing fails this method returns NULL and populates
        /// |error_code_out| and |error_msg_out| with an error code and a formatted error
        /// message respectively.
        /// </summary>
        public static CefValue ParseJsonAndReturnError(string value, CefJsonParserOptions options, out CefJsonParserError errorCode, out string errorMessage)
        {
            fixed(char *value_str = value)
            {
                var n_value = new cef_string_t(value_str, value != null ? value.Length : 0);

                CefJsonParserError n_error_code;
                cef_string_t       n_error_msg;
                var n_result = libcef.parse_jsonand_return_error(&n_value, options, &n_error_code, &n_error_msg);

                var result = CefValue.FromNativeOrNull(n_result);

                errorCode    = n_error_code;
                errorMessage = cef_string_userfree.ToString((cef_string_userfree *)&n_error_msg);
                return(result);
            }
        }
예제 #8
0
 /// <summary>
 /// Sets the value at the specified index. Returns true if the value was set
 /// successfully. If |value| represents simple data then the underlying data
 /// will be copied and modifications to |value| will not modify this object. If
 /// |value| represents complex data (binary, dictionary or list) then the
 /// underlying data will be referenced and modifications to |value| will modify
 /// this object.
 /// </summary>
 public bool SetValue(int index, CefValue value)
 {
     return(cef_list_value_t.set_value(_self, index, value.ToNative()) != 0);
 }
예제 #9
0
 /// <summary>
 /// Returns the value at the specified index. For simple types the returned
 /// value will copy existing data and modifications to the value will not
 /// modify this object. For complex types (binary, dictionary and list) the
 /// returned value will reference existing data and modifications to the value
 /// will modify this object.
 /// </summary>
 public CefValue GetValue(int index)
 {
     return(CefValue.FromNativeOrNull(
                cef_list_value_t.get_value(_self, index)
                ));
 }
예제 #10
0
 /// <summary>
 /// Returns a copy of this object. The underlying data will also be copied.
 /// </summary>
 public CefValue Copy()
 {
     return(CefValue.FromNative(
                cef_value_t.copy(_self)
                ));
 }
예제 #11
0
 /// <summary>
 /// Returns true if this object and |that| object have an equivalent underlying
 /// value but are not necessarily the same object.
 /// </summary>
 public bool IsEqual(CefValue that)
 {
     return(cef_value_t.is_equal(_self, that.ToNative()) != 0);
 }
예제 #12
0
 /// <summary>
 /// Returns true if this object and |that| object have the same underlying
 /// data. If true modifications to this object will also affect |that| object
 /// and vice-versa.
 /// </summary>
 public bool IsSame(CefValue that)
 {
     return(cef_value_t.is_same(_self, that.ToNative()) != 0);
 }
예제 #13
0
 /// <summary>
 /// Creates a new object.
 /// </summary>
 public static CefValue Create()
 {
     return(CefValue.FromNative(cef_value_t.create()));
 }