예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();

            services.AddEntityFramework().AddDbContext <TrollChatDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("Database")));

            services.AddSession();

            DependencyRegister.Register(services);

            QuartzDependencyRegister.Register(services);

            AutoMapperBuilder.Build();

            services.Configure <EmailServiceCredentials>(Configuration.GetSection(nameof(EmailServiceCredentials)));

            services.AddSignalR(options =>
            {
                options.Hubs.EnableDetailedErrors    = true;
                options.Hubs.EnableJavaScriptProxies = true;
            });

            services.AddAuthorization(options =>
            {
                options.AddPolicy("UserPolicy", policyBuilder =>
                {
                    policyBuilder.RequireAuthenticatedUser()
                    .RequireAssertion(context => context.User.HasClaim("Role", "User"))
                    .Build();
                });
            });

            // MiniProfiler
            services.AddMiniProfiler(options =>
            {
                // (Optional) Path to use for profiler URLs, default is /mini-profiler-resources
                options.RouteBasePath = "/profiler";

                // (Optional) Control which SQL formatter to use, InlineFormatter is the default
                options.SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter();

                // (Optional) Control storage
                // (default is 30 minutes in MemoryCacheStorage)
                ((MemoryCacheStorage)options.Storage).CacheDuration = TimeSpan.FromMinutes(30);
            }).AddEntityFramework();
            services.AddMemoryCache();
        }
예제 #2
0
        static void Main()
        {
            AutoMapperBuilder.Build();

            HostFactory.Run(x =>
            {
                x.Service <IssueService>(s =>
                {
                    s.ConstructUsing(obj => new IssueService());
                    s.WhenStarted(obj => obj.Start());
                    s.WhenStopped(obj => obj.Stop());
                });

                x.RunAsLocalSystem();

                x.SetDescription("Issues microservice for MunkeyIssues");
                x.SetDisplayName("MunkeyIssues Issues microservice");
                x.SetServiceName("MunkeyIssuesIssuesService");
            });
        }
예제 #3
0
 public AutoMapperFixture()
 {
     AutoMapperBuilder.Build();
 }