Exemple #1
0
        /// <summary>
        /// Gets the value associated with the specified key.
        /// </summary>
        /// <param name="key">The key of the value to get.</param>
        /// <exception cref="ArgumentNullException">key is null.</exception>
        /// <exception cref="KeyNotFoundException">
        /// The property is retrieved and key does not exist in the collection.
        /// </exception>
        public string this[string key]
        {
            get
            {
                if (key is null)
                {
                    throw new ArgumentNullException(nameof(key));

                    fixed(char *k = key)
                    {
                        cef_string_t s0 = new cef_string_t {
                            Str = k, Length = key.Length
                        };
                        cef_string_t s1    = new cef_string_t();
                        int          rv    = CefNativeApi.cef_string_map_find(Instance, &s0, &s1);
                        string       value = CefString.ReadAndFree(&s1);

                        if (rv == 0)
                        {
                            throw new KeyNotFoundException();
                        }
                        return(value);
                    }
            }

            set
            {
                throw new NotSupportedException();
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets the values associated with the specified key from the <see cref="CefStringMultimap"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="String"/> array that contains the values associated with
        /// the specified key from the <see cref="CefStringMultimap"/>, if found; otherwise, null.
        /// </returns>
        public string[] GetValues(string key)
        {
            fixed(char *s0 = key)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = key is null ? 0 : key.Length
                };
                uint count = (uint)CefNativeApi.cef_string_multimap_find_count(Instance, &cstr0);

                if (count == 0)
                {
                    return(null);
                }

                var cstr1  = new cef_string_t();
                var values = new string[count];

                for (uint i = 0; i < count; i++)
                {
                    if (CefNativeApi.cef_string_multimap_enumerate(Instance, &cstr0, new UIntPtr(i), &cstr1) == 0)
                    {
                        if (i == 0)
                        {
                            return(null);
                        }
                        Array.Resize(ref values, Math.Max((int)i, 0));
                        return(values);
                    }
                    values[i] = CefString.ReadAndFree(&cstr1);
                }
                return(values);
            }
        }
Exemple #3
0
        /// <summary>
        /// Returns the value of the attribute with the specified qualified name.
        /// The resulting string must be freed by calling cef_string_userfree_free().
        /// </summary>
        public unsafe virtual string GetAttributeByQName(string qualifiedName)
        {
            fixed(char *s0 = qualifiedName)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = qualifiedName != null ? qualifiedName.Length : 0
                };

                return(SafeCall(CefString.ReadAndFree(NativeInstance->GetAttributeByQName(&cstr0))));
            }
        }
Exemple #4
0
        /// <summary>
        /// Returns the first header value for |name| or an NULL string if not found.
        /// Will not return the Referer value if any. Use GetHeaderMap instead if
        /// |name| might have multiple values.
        /// The resulting string must be freed by calling cef_string_userfree_free().
        /// </summary>
        public unsafe virtual string GetHeaderByName(string name)
        {
            fixed(char *s0 = name)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = name != null ? name.Length : 0
                };

                return(SafeCall(CefString.ReadAndFree(NativeInstance->GetHeaderByName(&cstr0))));
            }
        }
Exemple #5
0
        /// <summary>
        /// Returns the element attribute named |attrName|.
        /// The resulting string must be freed by calling cef_string_userfree_free().
        /// </summary>
        public unsafe virtual string GetElementAttribute(string attrName)
        {
            fixed(char *s0 = attrName)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = attrName != null ? attrName.Length : 0
                };

                return(SafeCall(CefString.ReadAndFree(NativeInstance->GetElementAttribute(&cstr0))));
            }
        }
Exemple #6
0
        /// <summary>
        /// Returns a complete URL based on the document base URL and the specified
        /// partial URL.
        /// The resulting string must be freed by calling cef_string_userfree_free().
        /// </summary>
        public unsafe virtual string GetCompleteUrl(string partialURL)
        {
            fixed(char *s0 = partialURL)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = partialURL != null ? partialURL.Length : 0
                };

                return(SafeCall(CefString.ReadAndFree(NativeInstance->GetCompleteUrl(&cstr0))));
            }
        }
Exemple #7
0
        /// <summary>
        /// Returns the value at the specified key as type string.
        /// The resulting string must be freed by calling cef_string_userfree_free().
        /// </summary>
        public unsafe virtual string GetString(string key)
        {
            fixed(char *s0 = key)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = key != null ? key.Length : 0
                };

                return(SafeCall(CefString.ReadAndFree(NativeInstance->GetString(&cstr0))));
            }
        }
Exemple #8
0
        /// <summary>
        /// Returns the value of the entry at the specified index of the <see cref="CefStringMultimap"/>.
        /// </summary>
        /// <param name="index">The zero-based index of the entry to locate in the <see cref="CefStringMultimap"/>.</param>
        /// <returns>
        /// A <see cref="String"/> that contains the value of the entry at the specified index of the collection.
        /// </returns>
        public string Get(int index)
        {
            if (index < 0)
            {
                throw new IndexOutOfRangeException();
            }
            var cstr = new cef_string_t();

            if (CefNativeApi.cef_string_multimap_value(Instance, new UIntPtr((uint)index), &cstr) == 0)
            {
                throw new IndexOutOfRangeException();
            }
            return(CefString.ReadAndFree(&cstr));
        }
Exemple #9
0
        /// <summary>
        /// Gets the value of the entry at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index of the element to get.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <paramref name="index"/> is less than 0;
        /// or, <paramref name="index"/> is equal to or greater than <see cref="Count"/>.
        /// </exception>
        public string this[int index]
        {
            get
            {
                if (index < 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(index));
                }

                cef_string_t s0    = new cef_string_t();
                int          rv    = CefNativeApi.cef_string_map_value(Instance, new UIntPtr((uint)index), &s0);
                string       value = CefString.ReadAndFree(&s0);
                if (rv == 0)
                    throw new ArgumentOutOfRangeException(nameof(index)); }
                return(value);
Exemple #10
0
        public void CopyTo(string[] array, int arrayIndex)
        {
            cef_string_list_t instance = GetNativeInstance();
            var cstr0 = new cef_string_t();

            for (int i = 0; i < array.Length; i++)
            {
                if (CefNativeApi.cef_string_list_value(instance, unchecked ((UIntPtr)i), &cstr0) == 0)
                {
                    throw new InvalidOperationException();
                }

                array[i + arrayIndex] = CefString.ReadAndFree(&cstr0);
            }
        }
Exemple #11
0
        /// <summary>
        /// Returns the value of the attribute with the specified local name and
        /// namespace URI.
        /// The resulting string must be freed by calling cef_string_userfree_free().
        /// </summary>
        public unsafe virtual string GetAttributeByLName(string localName, string namespaceURI)
        {
            fixed(char *s0 = localName)
            fixed(char *s1 = namespaceURI)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = localName != null ? localName.Length : 0
                };
                var cstr1 = new cef_string_t {
                    Str = s1, Length = namespaceURI != null ? namespaceURI.Length : 0
                };

                return(SafeCall(CefString.ReadAndFree(NativeInstance->GetAttributeByLName(&cstr0, &cstr1))));
            }
        }
Exemple #12
0
 public string this[int index]
 {
     get
     {
         var cstr0 = new cef_string_t();
         if (CefNativeApi.cef_string_list_value(GetNativeInstance(), unchecked ((UIntPtr)index), &cstr0) != 0)
         {
             return(CefString.ReadAndFree(&cstr0));
         }
         throw new ArgumentOutOfRangeException(nameof(index));
     }
     set
     {
         throw new NotSupportedException();
     }
 }
Exemple #13
0
        /// <summary>
        /// Gets a value indicating whether the <see cref="CefStringMultimap"/> contains keys that are not null.
        /// </summary>
        /// <returns>true if the <see cref="CefStringMultimap"/> contains keys that are not null; otherwise, false.</returns>
        public bool HasKeys()
        {
            uint count = (uint)this.Count;

            for (uint i = 0; i < count; i++)
            {
                var cstr = new cef_string_t();
                if (CefNativeApi.cef_string_multimap_key(Instance, new UIntPtr(i), &cstr) == 0)
                {
                    return(false);
                }
                if (CefString.ReadAndFree(&cstr) != null)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #14
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>
        public unsafe virtual bool SetPreference(string name, CefValue value, ref string error)
        {
            fixed(char *s0 = name)
            fixed(char *s2 = error)
            {
                var cstr0 = new cef_string_t {
                    Str = s0, Length = name != null ? name.Length : 0
                };
                var cstr2 = new cef_string_t {
                    Str = s2, Length = error != null ? error.Length : 0
                };
                var rv = NativeInstance->SetPreference(&cstr0, (value != null) ? value.GetNativeInstance() : null, &cstr2) != 0;

                error = CefString.ReadAndFree(&cstr2);
                GC.KeepAlive(this);
                return(rv);
            }
        }
Exemple #15
0
        public string[] ToArray()
        {
            cef_string_list_t instance = GetNativeInstance();
            var cstr0 = new cef_string_t();

            var array = new string[this.Count];

            for (int i = 0; i < array.Length; i++)
            {
                if (CefNativeApi.cef_string_list_value(instance, unchecked ((UIntPtr)i), &cstr0) == 0)
                {
                    throw new InvalidOperationException();
                }

                array[i] = CefString.ReadAndFree(&cstr0);
            }
            return(array);
        }
Exemple #16
0
 /// <summary>
 /// Returns the label at the specified |index| or NULL if not found due to
 /// invalid range or the index being a separator.
 /// The resulting string must be freed by calling cef_string_userfree_free().
 /// </summary>
 public unsafe virtual string GetLabelAt(int index)
 {
     return(SafeCall(CefString.ReadAndFree(NativeInstance->GetLabelAt(index))));
 }
Exemple #17
0
 /// <summary>
 /// Returns the label for the specified |command_id| or NULL if not found.
 /// The resulting string must be freed by calling cef_string_userfree_free().
 /// </summary>
 public unsafe virtual string GetLabel(int commandId)
 {
     return(SafeCall(CefString.ReadAndFree(NativeInstance->GetLabel(commandId))));
 }
Exemple #18
0
 /// <summary>
 /// Returns the localized string for the specified |string_id| or an NULL
 /// string if the value is not found. Include cef_pack_strings.h for a listing
 /// of valid string ID values.
 /// The resulting string must be freed by calling cef_string_userfree_free().
 /// </summary>
 public unsafe virtual string GetLocalizedString(int stringId)
 {
     return(SafeCall(CefString.ReadAndFree(NativeInstance->GetLocalizedString(stringId))));
 }
Exemple #19
0
 /// <summary>
 /// Returns the underlying value as type string.
 /// The resulting string must be freed by calling cef_string_userfree_free().
 /// </summary>
 public unsafe virtual string GetString()
 {
     return(SafeCall(CefString.ReadAndFree(NativeInstance->GetString())));
 }
Exemple #20
0
 /// <summary>
 /// Returns the value of the attribute at the specified 0-based index.
 /// The resulting string must be freed by calling cef_string_userfree_free().
 /// </summary>
 public unsafe virtual string GetAttributeByIndex(int index)
 {
     return(SafeCall(CefString.ReadAndFree(NativeInstance->GetAttributeByIndex(index))));
 }
Exemple #21
0
 /// <summary>
 /// Returns the value at the specified index as type string.
 /// The resulting string must be freed by calling cef_string_userfree_free().
 /// </summary>
 public unsafe virtual string GetString(long index)
 {
     return(SafeCall(CefString.ReadAndFree(NativeInstance->GetString(new UIntPtr((ulong)index)))));
 }