Esempio n. 1
0
        /// <summary>
        /// Parses the specified |jsonString| and returns a dictionary or list
        /// representation. If JSON parsing fails this function returns NULL and
        /// populates |errorCodeOut| and |errorMsgOut| with an error code and a
        /// formatted error message respectively.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_parser_capi.h">cef/include/capi/cef_parser_capi.h</see>.
        /// </remarks>
        public static CfxValue ParseJsonAndReturnError(string jsonString, CfxJsonParserOptions options, out CfxJsonParserError errorCodeOut, ref string errorMsgOut)
        {
            var    jsonString_pinned = new PinnedString(jsonString);
            int    errorCodeOut_tmp;
            var    errorMsgOut_pinned = new PinnedString(errorMsgOut);
            IntPtr errorMsgOut_str    = errorMsgOut_pinned.Obj.PinnedPtr;
            int    errorMsgOut_length = errorMsgOut_pinned.Length;
            var    __retval           = CfxApi.cfx_parse_jsonand_return_error(jsonString_pinned.Obj.PinnedPtr, jsonString_pinned.Length, (int)options, out errorCodeOut_tmp, ref errorMsgOut_str, ref errorMsgOut_length);

            jsonString_pinned.Obj.Free();
            errorCodeOut = (CfxJsonParserError)errorCodeOut_tmp;
            if (errorMsgOut_str != errorMsgOut_pinned.Obj.PinnedPtr)
            {
                if (errorMsgOut_length > 0)
                {
                    errorMsgOut = System.Runtime.InteropServices.Marshal.PtrToStringUni(errorMsgOut_str, errorMsgOut_length);
                    // free the native string?
                }
                else
                {
                    errorMsgOut = null;
                }
            }
            errorMsgOut_pinned.Obj.Free();
            return(CfxValue.Wrap(__retval));
        }
Esempio n. 2
0
        /// <summary>
        /// Parses the specified |jsonString| and returns a dictionary or list
        /// representation. If JSON parsing fails this function returns NULL.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_parser_capi.h">cef/include/capi/cef_parser_capi.h</see>.
        /// </remarks>
        public static CfxValue ParseJson(string jsonString, CfxJsonParserOptions options)
        {
            var jsonString_pinned = new PinnedString(jsonString);
            var __retval          = CfxApi.cfx_parse_json(jsonString_pinned.Obj.PinnedPtr, jsonString_pinned.Length, (int)options);

            jsonString_pinned.Obj.Free();
            return(CfxValue.Wrap(__retval));
        }
Esempio n. 3
0
        /// <summary>
        /// Sets the value at the specified key. Returns true (1) 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>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
        /// </remarks>
        public bool SetValue(string key, CfxValue value)
        {
            var key_pinned = new PinnedString(key);
            var __retval   = CfxApi.DictionaryValue.cfx_dictionary_value_set_value(NativePtr, key_pinned.Obj.PinnedPtr, key_pinned.Length, CfxValue.Unwrap(value));

            key_pinned.Obj.Free();
            return(0 != __retval);
        }
Esempio n. 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 function must be
        /// called on the browser process UI thread.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>.
        /// </remarks>
        public CfxValue GetPreference(string name)
        {
            var name_pinned = new PinnedString(name);
            var __retval    = CfxApi.cfx_request_context_get_preference(NativePtr, name_pinned.Obj.PinnedPtr, name_pinned.Length);

            name_pinned.Obj.Free();
            return(CfxValue.Wrap(__retval));
        }
Esempio n. 5
0
        /// <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>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
        /// </remarks>
        public CfxValue GetValue(string key)
        {
            var key_pinned = new PinnedString(key);
            var __retval   = CfxApi.DictionaryValue.cfx_dictionary_value_get_value(NativePtr, key_pinned.Obj.PinnedPtr, key_pinned.Length);

            key_pinned.Obj.Free();
            return(CfxValue.Wrap(__retval));
        }
Esempio n. 6
0
        /// <summary>
        /// Set the |value| associated with preference |name|. Returns true (1) if the
        /// value is set successfully and false (0) 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 function must be called on the browser process UI thread.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>.
        /// </remarks>
        public bool SetPreference(string name, CfxValue value, out string error)
        {
            var    name_pinned = new PinnedString(name);
            IntPtr error_str;
            int    error_length;
            var    __retval = CfxApi.RequestContext.cfx_request_context_set_preference(NativePtr, name_pinned.Obj.PinnedPtr, name_pinned.Length, CfxValue.Unwrap(value), out error_str, out error_length);

            name_pinned.Obj.Free();
            if (error_length > 0)
            {
                error = System.Runtime.InteropServices.Marshal.PtrToStringUni(error_str, error_length);
                // free the native string?
            }
            else
            {
                error = null;
            }
            return(0 != __retval);
        }
Esempio n. 7
0
 internal static CfxValue Wrap(IntPtr nativePtr)
 {
     if (nativePtr == IntPtr.Zero)
     {
         return(null);
     }
     lock (weakCache) {
         var wrapper = (CfxValue)weakCache.Get(nativePtr);
         if (wrapper == null)
         {
             wrapper = new CfxValue(nativePtr);
             weakCache.Add(wrapper);
         }
         else
         {
             CfxApi.cfx_release(nativePtr);
         }
         return(wrapper);
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Generates a JSON string from the specified root |node| which should be a
 /// dictionary or list value. Returns an NULL string on failure. This function
 /// requires exclusive access to |node| including any underlying data.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_parser_capi.h">cef/include/capi/cef_parser_capi.h</see>.
 /// </remarks>
 public static string WriteJson(CfxValue node, CfxJsonWriterOptions options)
 {
     return(StringFunctions.ConvertStringUserfree(CfxApi.cfx_write_json(CfxValue.Unwrap(node), (int)options)));
 }
Esempio n. 9
0
 /// <summary>
 /// Sets the value at the specified index. Returns true (1) 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>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool SetValue(int index, CfxValue value)
 {
     return(0 != CfxApi.cfx_list_value_set_value(NativePtr, index, CfxValue.Unwrap(value)));
 }
Esempio n. 10
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>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public CfxValue GetValue(int index)
 {
     return(CfxValue.Wrap(CfxApi.cfx_list_value_get_value(NativePtr, index)));
 }
Esempio n. 11
0
 /// <summary>
 /// Creates a new object.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public static CfxValue Create()
 {
     return(CfxValue.Wrap(CfxApi.cfx_value_create()));
 }
Esempio n. 12
0
 /// <summary>
 /// Returns a copy of this object. The underlying data will also be copied.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public CfxValue Copy()
 {
     return(CfxValue.Wrap(CfxApi.cfx_value_copy(NativePtr)));
 }
Esempio n. 13
0
 /// <summary>
 /// Returns true (1) if this object and |that| object have an equivalent
 /// underlying value but are not necessarily the same object.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool IsEqual(CfxValue that)
 {
     return(0 != CfxApi.cfx_value_is_equal(NativePtr, CfxValue.Unwrap(that)));
 }
Esempio n. 14
0
 /// <summary>
 /// Returns true (1) if this object and |that| object have the same underlying
 /// data. If true (1) modifications to this object will also affect |that|
 /// object and vice-versa.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool IsSame(CfxValue that)
 {
     return(0 != CfxApi.cfx_value_is_same(NativePtr, CfxValue.Unwrap(that)));
 }
Esempio n. 15
0
 /// <summary>
 /// Sets the value at the specified index. Returns true (1) 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>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool SetValue(ulong index, CfxValue value)
 {
     return(0 != CfxApi.ListValue.cfx_list_value_set_value(NativePtr, (UIntPtr)index, CfxValue.Unwrap(value)));
 }
Esempio n. 16
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>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public CfxValue GetValue(ulong index)
 {
     return(CfxValue.Wrap(CfxApi.ListValue.cfx_list_value_get_value(NativePtr, (UIntPtr)index)));
 }