public static void AddBCFServer(this IServiceCollection services, Action <IServerOptionsBuilder> builderAction) { IServerOptionsBuilder builder = new ServerBCFOptionsBuilder(services); builderAction(builder); ServerBCFOptions serverOptions = builder.Build(); services.AddBlazorCommunicationFoundation(serverOptions); services.TryAddEnumerable(serverOptions.InvocationSerializerTypes.Select(type => new ServiceDescriptor(typeof(IInvocationSerializer), type, ServiceLifetime.Singleton))); services.AddSingleton <IMethodInvoker, DelegateMethodInvoker>(); services.AddTransient <IAuthorizationContextProvider, AuthorizationContextProvider>(); services.AddTransient <IAuthorizationHandler, AuthorizationHandler>(); services.AddTransient <IContractImplementationResolver, ServiceProviderContractImplementationResolver>(); services.AddTransient <ContractMethodInvocationHandler>(); }
ServerBCFOptions IOptionsBuilder <ServerBCFOptions> .Build() { if (serverOptions != null) { return(serverOptions); } serverOptions = new ServerBCFOptions(); Build(serverOptions); serverOptions.Contracts = Contracts; foreach (var serializerType in invocationSerializerTypes) { serverOptions.InvocationSerializerTypes.Add(serializerType); } return(serverOptions); }