Beispiel #1
0
        /// <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);
            }
        }