static MetadataServiceSerializer()
 {
     TypeModel           = CreateRuntimeTypeModel();
     BinderConfiguration = BinderConfiguration.Create(new[] { ProtoBufMarshallerFactory.Create(TypeModel, ProtoBufMarshallerFactory.Options.None) });
     ClientFactory       = ClientFactory.Create(BinderConfiguration);
 }
        public static void AddGrpcServerInfrastructure(
            this IServiceCollection services,
            Assembly assemblyToScanForDataContracts,
            Action <GrpcServiceOptions> configureOptions = null)
        {
            services.AddSingleton <GlobalizationLocalizationGrpcServerInterceptor>();
            services.AddSingleton <ServerExceptionsGrpcServerInterceptor>();
            services.AddSingleton(BinderConfiguration.Create(marshallerFactories: new[] { ProtoBufMarshallerFactory.Create(RuntimeTypeModel.Create().RegisterApplicationContracts(assemblyToScanForDataContracts)) }, binder: new ServiceBinderWithServiceResolutionFromServiceCollection(services)));

            services.AddCodeFirstGrpc(options =>
            {
                options.Interceptors.Add <GlobalizationLocalizationGrpcServerInterceptor>();
                options.Interceptors.Add <ServerExceptionsGrpcServerInterceptor>();
                options.ResponseCompressionLevel = System.IO.Compression.CompressionLevel.Optimal;

                configureOptions?.Invoke(options);
            });
        }
Beispiel #3
0
 public static void AddGrpcClientInfrastructure(this IServiceCollection services)
 {
     services.AddTransient <AuthorizationGrpcClientInterceptor>();
     services.AddTransient <ServerExceptionsGrpcClientInterceptor>();
     services.AddTransient <GrpcWebHandler>(provider => new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler()));
     services.AddSingleton <ClientFactory>(ClientFactory.Create(BinderConfiguration.Create(marshallerFactories: new[] { ProtoBufMarshallerFactory.Create(RuntimeTypeModel.Create().RegisterApplicationContracts()) }, binder: new ProtoBufServiceBinder())));
 }
        public void ConfigureServices(IServiceCollection services)
        {
            services.ConfigureForWebServer(configuration);

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            services.AddDatabaseDeveloperPageExceptionFilter();

            services.AddOptions();

            services.AddCustomizedMailing(configuration);

            // SmtpExceptionMonitoring to [email protected]
            services.AddExceptionMonitoring(configuration);

            // Application Insights
            services.AddApplicationInsightsTelemetry(configuration);
            services.AddSingleton <ITelemetryInitializer, GrpcRequestStatusTelemetryInitializer>();
            services.AddSingleton <ITelemetryInitializer, EnrichmentTelemetryInitializer>();
            services.ConfigureTelemetryModule <DependencyTrackingTelemetryModule>((module, o) => { module.EnableSqlCommandTextInstrumentation = true; });

            services.AddCustomizedAuth(configuration);

            // server-side UI
            services.AddControllersWithViews();
            services.AddRazorPages();

            // gRPC
            services.AddSingleton <ServerExceptionsGrpcServerInterceptor>();
            services.AddSingleton(BinderConfiguration.Create(marshallerFactories: new[] { ProtoBufMarshallerFactory.Create(RuntimeTypeModel.Default.RegisterApplicationContracts()) }, binder: new ServiceBinderWithServiceResolutionFromServiceCollection(services)));
            services.AddCodeFirstGrpc(config =>
            {
                config.Interceptors.Add <ServerExceptionsGrpcServerInterceptor>();
                config.ResponseCompressionLevel = System.IO.Compression.CompressionLevel.Optimal;
            });
        }
 private static BinderConfiguration CreateBinderConfiguration()
 {
     return(BinderConfiguration.Create(new[] { ProtoBufMarshallerFactory.Create(CreateModel(), ProtoBufMarshallerFactory.Options.None) }));
 }
 public static BinderConfiguration CreateBinderConfiguration(ServiceBinder?serviceBinder = null) =>
 BinderConfiguration.Create(new[] { ProtoBufMarshallerFactory.Create(ProtoBufSerializer.TypeModel) }, serviceBinder);
Beispiel #7
0
 public static void AddGrpcClientInfrastructure(
     this IServiceCollection services,
     Assembly assemblyToScanForDataContracts)
 {
     services.AddTransient <ServerExceptionsGrpcClientInterceptor>();
     services.AddSingleton <GlobalizationLocalizationGrpcClientInterceptor>();
     services.AddSingleton <ClientUriGrpcClientInterceptor>();
     services.AddTransient <CancellationWorkaroundGrpcClientInterceptor>();
     services.AddTransient <GrpcWebHandler>(provider => new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler()));
     services.AddSingleton <ClientFactory>(ClientFactory.Create(BinderConfiguration.Create(marshallerFactories: new[] { ProtoBufMarshallerFactory.Create(RuntimeTypeModel.Create().RegisterApplicationContracts(assemblyToScanForDataContracts)) }, binder: new ProtoBufServiceBinder())));
 }