/// <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(); } }
/// <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); } }
private static unsafe void VisitImpl(cef_string_visitor_t *self, cef_string_t * @string) { var instance = GetInstance((IntPtr)self) as CefStringVisitor; if (instance == null || ((ICefStringVisitorPrivate)instance).AvoidVisit()) { return; } instance.Visit(CefString.Read(@string)); }
private static unsafe void IsUnstableImpl(cef_web_plugin_unstable_callback_t *self, cef_string_t *path, int unstable) { var instance = GetInstance((IntPtr)self) as CefWebPluginUnstableCallback; if (instance == null || ((ICefWebPluginUnstableCallbackPrivate)instance).AvoidIsUnstable()) { return; } instance.IsUnstable(CefString.Read(path), unstable != 0); }
// void (*)(_cef_end_tracing_callback_t* self, const cef_string_t* tracing_file)* private static unsafe void OnEndTracingCompleteImpl(cef_end_tracing_callback_t *self, cef_string_t *tracing_file) { var instance = GetInstance((IntPtr)self) as CefEndTracingCallback; if (instance == null || ((ICefEndTracingCallbackPrivate)instance).AvoidOnEndTracingComplete()) { return; } instance.OnEndTracingComplete(CefString.Read(tracing_file)); }
private static unsafe void OnPdfPrintFinishedImpl(cef_pdf_print_callback_t *self, cef_string_t *path, int ok) { var instance = GetInstance((IntPtr)self) as CefPdfPrintCallback; if (instance == null || ((ICefPdfPrintCallbackPrivate)instance).AvoidOnPdfPrintFinished()) { return; } instance.OnPdfPrintFinished(CefString.Read(path), ok != 0); }
// void (*)(_cef_register_cdm_callback_t* self, cef_cdm_registration_error_t result, const cef_string_t* error_message)* private static unsafe void OnCDMRegistrationCompleteImpl(cef_register_cdm_callback_t *self, CefCDMRegistrationError result, cef_string_t *error_message) { var instance = GetInstance((IntPtr)self) as CefRegisterCDMCallback; if (instance == null || ((ICefRegisterCDMCallbackPrivate)instance).AvoidOnCDMRegistrationComplete()) { return; } instance.OnCDMRegistrationComplete(result, CefString.Read(error_message)); }
/// <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)))); } }
// void (*)(_cef_media_route_create_callback_t* self, cef_media_route_create_result_t result, const cef_string_t* error, _cef_media_route_t* route)* private static unsafe void OnMediaRouteCreateFinishedImpl(cef_media_route_create_callback_t *self, CefMediaRouteCreateResult result, cef_string_t *error, cef_media_route_t *route) { var instance = GetInstance((IntPtr)self) as CefMediaRouteCreateCallback; if (instance == null || ((ICefMediaRouteCreateCallbackPrivate)instance).AvoidOnMediaRouteCreateFinished()) { ReleaseIfNonNull((cef_base_ref_counted_t *)route); return; } instance.OnMediaRouteCreateFinished(result, CefString.Read(error), CefMediaRoute.Wrap(CefMediaRoute.Create, route)); }
/// <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)))); } }
private static unsafe void OnDownloadImageFinishedImpl(cef_download_image_callback_t *self, cef_string_t *image_url, int http_status_code, cef_image_t *image) { var instance = GetInstance((IntPtr)self) as CefDownloadImageCallback; if (instance == null || ((ICefDownloadImageCallbackPrivate)instance).AvoidOnDownloadImageFinished()) { ReleaseIfNonNull((cef_base_ref_counted_t *)image); return; } instance.OnDownloadImageFinished(CefString.Read(image_url), http_status_code, CefImage.Wrap(CefImage.Create, image)); }
/// <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)))); } }
/// <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)))); } }
// void (*)(_cef_app_t* self, const cef_string_t* process_type, _cef_command_line_t* command_line)* private static unsafe void OnBeforeCommandLineProcessingImpl(cef_app_t *self, cef_string_t *process_type, cef_command_line_t *command_line) { var instance = GetInstance((IntPtr)self) as CefApp; if (instance == null || ((ICefAppPrivate)instance).AvoidOnBeforeCommandLineProcessing()) { ReleaseIfNonNull((cef_base_ref_counted_t *)command_line); return; } instance.OnBeforeCommandLineProcessing(CefString.Read(process_type), CefCommandLine.Wrap(CefCommandLine.Create, command_line)); }
// void (*)(_cef_display_handler_t* self, _cef_browser_t* browser, const cef_string_t* title)* private static unsafe void OnTitleChangeImpl(cef_display_handler_t *self, cef_browser_t *browser, cef_string_t *title) { var instance = GetInstance((IntPtr)self) as CefDisplayHandler; if (instance == null || ((ICefDisplayHandlerPrivate)instance).AvoidOnTitleChange()) { ReleaseIfNonNull((cef_base_ref_counted_t *)browser); return; } instance.OnTitleChange(CefBrowser.Wrap(CefBrowser.Create, browser), CefString.Read(title)); }
/// <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)))); } }
/// <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)); }
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); } }
/// <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);
/// <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)))); } }
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(); } }
/// <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); }
/// <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); } }
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); }
/// <summary> /// Copies the V8 string into <see cref="CefValue"/> object. /// </summary> /// <param name="value">The destination <see cref="CefValue"/> object.</param> /// <returns>Returns true if the value was set successfully.</returns> public bool CopyV8StringToCefValue(CefValue value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (!IsString) { throw new InvalidOperationException(); } cef_string_userfree_t userfreeStr = NativeInstance->GetStringValue(); try { return(value.NativeInstance->SetString((cef_string_t *)userfreeStr.Base.Base) != 0); } finally { CefString.Free(userfreeStr); GC.KeepAlive(this); } }
private static unsafe void OnLoadErrorImpl(cef_load_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, CefErrorCode errorCode, cef_string_t *errorText, cef_string_t *failedUrl) { var instance = GetInstance((IntPtr)self) as CefLoadHandler; if (instance == null || ((ICefLoadHandlerPrivate)instance).AvoidOnLoadError()) { ReleaseIfNonNull((cef_base_ref_counted_t *)browser); ReleaseIfNonNull((cef_base_ref_counted_t *)frame); return; } instance.OnLoadError(CefBrowser.Wrap(CefBrowser.Create, browser), CefFrame.Wrap(CefFrame.Create, frame), errorCode, CefString.Read(errorText), CefString.Read(failedUrl)); }
/// <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)))); }
/// <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)))); }
/// <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)))); }
private static unsafe void OnWebSocketRequestImpl(cef_server_handler_t *self, cef_server_t *server, int connection_id, cef_string_t *client_address, cef_request_t *request, cef_callback_t *callback) { var instance = GetInstance((IntPtr)self) as CefServerHandler; if (instance == null || ((ICefServerHandlerPrivate)instance).AvoidOnWebSocketRequest()) { ReleaseIfNonNull((cef_base_ref_counted_t *)server); ReleaseIfNonNull((cef_base_ref_counted_t *)request); ReleaseIfNonNull((cef_base_ref_counted_t *)callback); return; } instance.OnWebSocketRequest(CefServer.Wrap(CefServer.Create, server), connection_id, CefString.Read(client_address), CefRequest.Wrap(CefRequest.Create, request), CefCallback.Wrap(CefCallback.Create, callback)); }