Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(c =>
                             c.AddPolicy(MyAllowSpecificOrigins, b => { b.AllowAnyHeader().AllowAnyMethod().WithOrigins("http://localhost:4200", "https://www.dmyblog.co"); })
                             );
            ServiceCollectionServiceExtensions.AddScoped <SharesSevice>(services);
            services.AddSingleton <IEmailConfiguration>(Configuration.GetSection("EmailConfiguration").Get <EmailConfiguration>());
            services.AddTransient <IEmailService, EmailService>();

            services.Configure <BrotliCompressionProviderOptions>(options =>
            {
                options.Level = CompressionLevel.Optimal;
            });

            services.AddResponseCompression(options =>
            {
                IEnumerable <string> MimeTypes = new[]
                {
                    "text/plain",
                    "text/css",
                    "font/woff2",
                    "application/javascript",
                    "image/x-icon",
                    "image/png", "image/jpeg"
                };
                options.EnableForHttps = true;
                options.MimeTypes      = MimeTypes;
                options.Providers.Add <GzipCompressionProvider>();
                options.Providers.Add <BrotliCompressionProvider>();
            });

            services.AddControllersWithViews();
        }
Ejemplo n.º 2
0
		public void AddCoreServices(IServiceCollection services)
		{
			ServiceCollectionDescriptorExtensions.TryAddScoped<IShellStateUpdater, ShellStateUpdater>(services);
			ServiceCollectionDescriptorExtensions.TryAddScoped<IShellStateManager, NullShellStateManager>(services);
			dummyVar0 = ServiceCollectionServiceExtensions.AddScoped<IShellDescriptorManagerEventHandler, ShellStateCoordinator>(services);
			return;
		}
Ejemplo n.º 3
0
 void IServiceAttribute.AddService(
     IServiceCollection services,
     Type serviceType,
     Func <IServiceProvider, object> implementationFactory)
 {
     ServiceCollectionServiceExtensions.AddScoped(
         services,
         serviceType,
         implementationFactory);
 }
Ejemplo n.º 4
0
 void IServiceAttribute.AddService(
     IServiceCollection services,
     Type serviceType,
     Type implementationType)
 {
     ServiceCollectionServiceExtensions.AddScoped(
         services,
         serviceType,
         implementationType);
 }
        public static void RegisterAllRequestResponses(IServiceCollection services, Func <Type, RegisterAllRequestResponsesOptions> onConfigure = null)
        {
            RegisterAllRequestResponsesOptions registerConfig = null;

            //we should change this part of configuration because multiple invoke of onConfigure
            if (onConfigure != null)
            {
                registerConfig = onConfigure(null);
            }
            else
            {
                registerConfig = new RegisterAllRequestResponsesOptions
                {
                    timeout      = TimeSpan.FromSeconds(10),
                    rabbitmqHost = "localhost:5672",
                    namespaces   = new string[] { "" }
                };
            }

            List <TypeInfo> consumersTypes = GetSpecificConsumers(typeof(IRequestResponse), registerConfig.namespaces);

            foreach (TypeInfo consType in consumersTypes)
            {
                Type responseType = null, requestType = null;

                foreach (var genericType in consType.GetInterfaces())
                {
                    if (genericType.IsGenericType && genericType.GetGenericTypeDefinition() == typeof(IRequestResponse <>))
                    {
                        responseType = genericType.GetGenericArguments()[0]; //response type
                    }
                    else if (genericType.IsGenericType && genericType.GetGenericTypeDefinition() == typeof(IConsumer <>))
                    {
                        requestType = genericType.GetGenericArguments()[0]; //request type
                    }
                }

                Uri serviceAddress = new Uri($"rabbitmq://{registerConfig.rabbitmqHost}/{consType.Name}");

                var requestClientGenericType = typeof(IRequestClient <,>).MakeGenericType(new Type[] { requestType, responseType });

                ServiceCollectionServiceExtensions.AddScoped(services, requestClientGenericType, new Func <IServiceProvider, object>(sp =>
                {
                    if (onConfigure != null)
                    {
                        registerConfig = onConfigure(consType);
                    }

                    return(Activator.CreateInstance(typeof(MessageRequestClient <,>).MakeGenericType(requestType, responseType),
                                                    args: new object[] {
                        sp.GetRequiredService <IBus>(), serviceAddress, registerConfig.timeout, registerConfig.timeout, null
                    }));
                }));
            }
        }
Ejemplo n.º 6
0
        public static IServiceCollection AddBusinessServices(this IServiceCollection services)
        {
            ServiceCollectionServiceExtensions.AddScoped <IYetkilimUnitOfWork, YetkilimUnitOfWork>(services);
            ServiceCollectionServiceExtensions.AddScoped <IPlaceService, PlaceService>(services);
            ServiceCollectionServiceExtensions.AddScoped <IFeedbackService, FeedbackService>(services);
            ServiceCollectionServiceExtensions.AddScoped <ICompanyService, CompanyService>(services);
            ServiceCollectionServiceExtensions.AddScoped <IUserService, UserService>(services);
            ServiceCollectionServiceExtensions.AddScoped <IPanelUserService, PanelUserService>(services);
            ServiceCollectionServiceExtensions.AddScoped <IPromotionService, PromotionService>(services);
            ServiceCollectionServiceExtensions.AddScoped <IEmailSender, EmailSender>(services);
            ServiceCollectionServiceExtensions.AddScoped <ICompanyFeedbackService, CompanyFeedbackService>(services);

            return(services);
        }
        /// <summary>
        /// Adds LiteX SQLite Cache manager services
        /// </summary>
        /// <param name="services"></param>
        /// <param name="options">Option setup.</param>
        /// <returns></returns>
        public static IServiceCollection AddLiteXSQLiteCache(this IServiceCollection services, Action <SQLiteConfig> options)
        {
            //IL_001d: Unknown result type (might be due to invalid IL or missing references)
            //IL_002b: Unknown result type (might be due to invalid IL or missing references)
            //IL_0032: Unknown result type (might be due to invalid IL or missing references)
            //IL_0039: Unknown result type (might be due to invalid IL or missing references)
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            SQLiteConfig sQLiteConfig = new SQLiteConfig();

            options(sQLiteConfig);
            ServiceCollectionServiceExtensions.AddSingleton <SQLiteConfig>(services, sQLiteConfig);
            services.AddLiteXPerRequestCache();
            ServiceCollectionServiceExtensions.AddSingleton <ISQLiteConnectionProvider, SQLiteConnectionProvider>(services);
            ServiceCollectionServiceExtensions.AddScoped <ILiteXCacheManager, SQLiteCacheManager>(services);
            ServiceCollectionServiceExtensions.AddScoped <ILiteXCacheManagerAsync, SQLiteCacheManager>(services);
            return(services);
        }
 public static void AddUserContextLoader(this IServiceCollection services)
 {
     ServiceCollectionServiceExtensions.AddScoped(services, x => x.GetUserContext(new UserContext()));
     ServiceCollectionServiceExtensions.AddScoped <IUserContextLoader, UserContextLoader>(services);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Adds LiteX per http request cache manager services
 /// Life: Scoped
 /// </summary>
 /// <param name="services"></param>
 /// <returns></returns>
 public static IServiceCollection AddLiteXPerRequestCache(this IServiceCollection services)
 {
     //IL_0001: Unknown result type (might be due to invalid IL or missing references)
     ServiceCollectionServiceExtensions.AddScoped <ICacheManager, PerRequestCacheManager>(services);
     return(services);
 }
Ejemplo n.º 10
0
 public static IServiceCollection AddAllFeaturesDescriptor(this IServiceCollection services)
 {
     dummyVar0 = ServiceCollectionServiceExtensions.AddScoped <IShellDescriptorManager, AllFeaturesShellDescriptorManager>(services);
     return(services);
 }