/// <summary>
 /// Registers blazor download file service
 /// </summary>
 /// <param name="services"></param>
 /// <param name="lifetime"></param>
 /// <returns></returns>
 public static IServiceCollection AddBlazorDownloadFile(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Scoped)
 {
     return(ServiceCollectionDescriptorExtensions.Add(services,
                                                      new ServiceDescriptor(typeof(IBlazorDownloadFileService),
                                                                            sp => new BlazorDownloadFileService(sp.GetRequiredService <IJSRuntime>()),
                                                                            lifetime)));
 }
 void System.Collections.Generic.ICollection <Microsoft.Extensions.DependencyInjection.ServiceDescriptor> .Add(ServiceDescriptor item)
 {
     this._innerServiceCollection.Add(item);
     stackVariable4 = this._currentFeatureServiceCollection;
     if (stackVariable4 == null)
     {
         dummyVar0 = stackVariable4;
         return;
     }
     dummyVar1 = ServiceCollectionDescriptorExtensions.Add(stackVariable4, item);
     return;
 }
 public void Insert(int index, ServiceDescriptor item)
 {
     this._innerServiceCollection.Insert(index, item);
     stackVariable5 = this._currentFeatureServiceCollection;
     if (stackVariable5 == null)
     {
         dummyVar0 = stackVariable5;
         return;
     }
     dummyVar1 = ServiceCollectionDescriptorExtensions.Add(stackVariable5, item);
     return;
 }
Пример #4
0
        public static IServiceCollection AddMessageProcessor <TMessage, TMessageProcessor>(
            this IServiceCollection serviceCollection,
            Action <IServiceProvider, AzureStorageQueueWorkerOptionsBuilder> optionsAction,
            ServiceLifetime serviceLifetime = ServiceLifetime.Scoped,
            bool configureTelemetry         = true,
            bool avoidMessageSampling       = true)
            where TMessageProcessor : IMessageProcessor <TMessage>
        {
            if (!_timeoutConfigured)
            {
                _timeoutConfigured = true;
                serviceCollection.PostConfigure <HostOptions>(o => o.ShutdownTimeout = TimeSpan.FromSeconds(20));
            }

            if (configureTelemetry && !_telemetryConfigured)
            {
                _telemetryConfigured = true;
                serviceCollection.AddApplicationInsightsTelemetryWorkerService();
                serviceCollection.ConfigureTelemetryModule <DependencyTrackingTelemetryModule>((module, o) => { module.EnableSqlCommandTextInstrumentation = true; });
            }

            if (avoidMessageSampling)
            {
                ServiceCollectionDescriptorExtensions
                .Add(
                    serviceCollection,
                    new ServiceDescriptor(
                        typeof(ITelemetryInitializer),
                        CreateAvoidSamplingTelemetryInitializer <TMessageProcessor>,
                        ServiceLifetime.Singleton));
            }

            serviceCollection.TryAdd(
                new ServiceDescriptor(
                    typeof(AzureStorageQueueWorkerOptions <TMessageProcessor>),
                    p => CreateAzureStorageQueueWorkerOptions <TMessage, TMessageProcessor>(p, optionsAction),
                    ServiceLifetime.Singleton));

            serviceCollection.TryAdd(
                new ServiceDescriptor(
                    typeof(TMessageProcessor),
                    typeof(TMessageProcessor),
                    serviceLifetime));

            serviceCollection.AddHostedService <AzureStorageQueueWorker <TMessage, TMessageProcessor> >();

            return(serviceCollection);
        }