public FileReaderService(IJSRuntime jsRuntime, FileReaderServiceOptions options, IServiceProvider serviceProvider) { this.Options = options; if (!PlatformConfig.IsWasm) { if (MaximumReceiveMessageSize == null) { if (!PlatformConfig.TryReadMaximumReceiveMessageSize(serviceProvider, out var maximumRecieveMessageSize)) { System.Diagnostics.Trace.TraceWarning($"{typeof(FileReaderService).FullName}: Unable to read SignalR MaximumReceiveMessageSize, defaulting to {DefaultMaximumReceiveMessageSize}"); MaximumReceiveMessageSize = DefaultMaximumReceiveMessageSize; } else { MaximumReceiveMessageSize = maximumRecieveMessageSize; } } options.UseBufferChunking = true; options.MaximumRecieveMessageSize = MaximumReceiveMessageSize.Value; } this._fileReaderJsInterop = new FileReaderJsInterop(jsRuntime, options); }
/// <summary> /// Adds <see cref="IFileReaderService"/> as a scoped service /// to the specified <see cref="IServiceCollection"/> with the specifed <paramref name="setOptions"/> /// </summary> /// <param name="services"></param> /// <param name="setOptions">Delegate that modifies the options for <see cref="IFileReaderService"/> </param> public static IServiceCollection AddFileReaderService(this IServiceCollection services, Action <IFileReaderServiceOptions> setOptions) { if (setOptions is null) { throw new ArgumentNullException(nameof(setOptions)); } services.AddSingleton(si => { var o = new FileReaderServiceOptions(); setOptions(o); return(o); }); services.AddScoped <IFileReaderService, FileReaderService>(); return(services); }
/// <summary> /// Adds <see cref="IFileReaderService"/> as a scoped service /// to the specified <see cref="IServiceCollection"/> with the specifed <paramref name="setOptions"/> /// </summary> /// <param name="services"></param> /// <param name="setOptions">Delegate that modifies the options for <see cref="IFileReaderService"/> </param> public static IServiceCollection AddFileReaderService(this IServiceCollection services, Action <IFileReaderServiceOptions> setOptions) { if (setOptions is null) { throw new ArgumentNullException(nameof(setOptions)); } services.AddSingleton <IFileReaderServiceOptions, FileReaderServiceOptions>(si => { var o = new FileReaderServiceOptions(); setOptions(o); if (o.UseWasmSharedBuffer && !IJSRuntimeExtensions.IsInvokeUnmarshalledSupported()) { throw new PlatformNotSupportedException($"{nameof(o.UseWasmSharedBuffer)}=true is not supported on this platform."); } return(o); }); services.AddScoped <IFileReaderService, FileReaderService>(); return(services); }
internal FileReaderJsInterop(IJSRuntime jsRuntime, FileReaderServiceOptions options) { CurrentJSRuntime = jsRuntime; _options = options; _needsInitialization = options.InitializeOnFirstCall; }