Exemplo n.º 1
0
        public void RendererRegistry_Find_ThrowsErrorOnNonWASM()
        {
            // Act
            Exception ex = Assert.Throws <ArgumentException>(() => RendererRegistry.Find(123));

            // Assert
            Assert.Equal("There is no renderer with ID 123.", ex.Message);
        }
Exemplo n.º 2
0
        public void RendererRegistry_Remove_DoesNothingOnNonWASM()
        {
            // Act
            var result = RendererRegistry.TryRemove(123);

            // Assert
            Assert.False(result);
        }
Exemplo n.º 3
0
        public static Task DispatchEvent(WebEventDescriptor eventDescriptor, string eventArgsJson)
        {
            var webEvent = WebEventData.Parse(eventDescriptor, eventArgsJson);
            var renderer = RendererRegistry.Find(eventDescriptor.BrowserRendererId);

            return(renderer.DispatchEventAsync(
                       webEvent.EventHandlerId,
                       webEvent.EventFieldInfo,
                       webEvent.EventArgs));
        }
Exemplo n.º 4
0
 /// <inheritdoc />
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     RendererRegistry.TryRemove(_webAssemblyRendererId);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructs an instance of <see cref="WebAssemblyRenderer"/>.
 /// </summary>
 /// <param name="serviceProvider">The <see cref="IServiceProvider"/> to use when initializing components.</param>
 /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
 public WebAssemblyRenderer(IServiceProvider serviceProvider, ILoggerFactory loggerFactory)
     : base(serviceProvider, loggerFactory)
 {
     // The WebAssembly renderer registers and unregisters itself with the static registry
     _webAssemblyRendererId = RendererRegistry.Add(this);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Framework infrastructure, not intended by used by application code.
 /// </summary>
 public static void SetCurrentRendererRegistry(RendererRegistry registry)
 {
     _current.Value = registry;
 }
Exemplo n.º 7
0
 // By default the registry will be set to a default value. This means that
 // things will 'just work when running in the browser.
 //
 // Running in Server-Side Blazor - any call into the Circuit will set this value via
 // the async local. This will ensure that the incoming call can resolve the correct
 // renderer associated with the user context.
 static RendererRegistry()
 {
     _current        = new AsyncLocal <RendererRegistry>();
     _globalRegistry = new RendererRegistry();
 }