Beispiel #1
0
        public async ValueTask <string?> GetCookieAsync(string name)
        {
            _ = name ?? throw new ArgumentNullException(nameof(name));

            var module = await _jsRuntime
                         .ImportOrGetModuleAsync(ModulePath, ModuleKey, _jsRefStore);

            return(await module.InvokeAsync <string>(
                       "getCookie",
                       name));
        }
Beispiel #2
0
        /// <inheritdoc/>
        public async ValueTask <bool> WriteAsync(string?value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(false);
            }

            var module = await _jsRuntime
                         .ImportOrGetModuleAsync(ModulePath, ModuleKey, _jsRefStore);

            return(await module !.InvokeAsync <bool>(
                       "writeText",
                       value));
        }
Beispiel #3
0
        public async Task AddEventHandlerAsync <TArgument>(string eventName, Action <TArgument?> handler)
            where TArgument : EventArgs
        {
            var module = await _jsRuntime
                         .ImportOrGetModuleAsync(WindowService.ModulePath, WindowService.ModuleKey, _jsRefStore);

            if (AddEventHandlerInternal(eventName, handler))
            {
                // Add inital event-handler for the given event
                await module.InvokeVoidAsync(
                    "addEventHandler",
                    eventName,
                    nameof(HandleEventCallback),
                    DotNetObjectReference.Create(this));
            }
        }
Beispiel #4
0
        public async ValueTask SetTitleAsync(string?value)
        {
            var module = await _jsRuntime
                         .ImportOrGetModuleAsync(ModulePath, ModuleKey, _jsRefStore);

            await module.InvokeVoidAsync(
                "setTitle",
                value);
        }
Beispiel #5
0
        public async ValueTask OpenAsync(string?url, string?windowName)
        {
            var module = await _jsRuntime
                         .ImportOrGetModuleAsync(ModulePath, ModuleKey, _jsRefStore);

            await module.InvokeVoidAsync(
                "open",
                url,
                windowName);
        }
Beispiel #6
0
        public async ValueTask <bool> InsertMarkupAsync(string parentSelector, string?value, InsertionPosition position, MarkupType type)
        {
            _ = parentSelector ?? throw new ArgumentNullException(nameof(parentSelector));

            var module = await _jsRuntime
                         .ImportOrGetModuleAsync(ModulePath, ModuleKey, _jsRefStore);

            return(await module.InvokeAsync <bool>(
                       "insertMarkup",
                       parentSelector,
                       value,
                       MapInsertionPosition(position),
                       MapMarkupType(type)));
        }