Пример #1
0
        public void Configuration(IAppBuilder app)
        {
            //Configure AutoMapper (http://automapper.codeplex.com/)
            Mapper.Initialize(ConfigureMapper);

            //Configure Bearer Authentication
            OAuthOptions = new OAuthAuthorizationServerOptions();
            app.UseOAuthBearerTokens(OAuthOptions);

            //Configure AutoFac for DependencyResolver (http://autofac.org/)
            IContainer container = RegisterServices();
            var resolverForSignalr = new Autofac.Integration.SignalR.AutofacDependencyResolver(container);
            var resolver = new App.Common.AutoFacDependencyResolver(container);

            //Configure WebApi
            var config = new HttpConfiguration() { DependencyResolver = resolver };
            ConfigureWebApi(config);
            app.UseWebApi(config);

            //Configure SignalR self host
            var hubConfiguration = new HubConfiguration() { Resolver = resolverForSignalr };
            app.MapSignalR(hubConfiguration);

            //Log trafic using Log4Net
            app.Use(typeof(Logging));

            // container.Resolve<IRavenRepository>();

            //Set global dependency resolver for signalr
            GlobalHost.DependencyResolver = resolverForSignalr;
        }
Пример #2
0
        public void ConfigureSignalR(IAppBuilder app, IContainer container)
        {
            var jsonSettings = new JsonSerializerSettings();

            jsonSettings.ContractResolver = new SignalRContractResolver();
            var serializer = JsonSerializer.Create(jsonSettings);

            var resolver = new Autofac.Integration.SignalR.AutofacDependencyResolver(container);

            resolver.Register(typeof(JsonSerializer), () => serializer);
            resolver.Register(typeof(IUserIdProvider), () => new CustomUserIdProvider());

            AutofacConfig.RegisterHubTypes(resolver).Update(container);

            app.Map("/signalr", map =>
            {
                map.UseCors(CorsOptions.AllowAll);

                map.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions()
                {
                    Provider = new QueryStringOAuthBearerProvider()
                });

                map.RunSignalR(new HubConfiguration
                {
                    Resolver = resolver
                });
            });
        }
Пример #3
0
        public void Configuration(IAppBuilder app)
        {
            IoC.AutoFac.Configurator.Initialize(Assembly.GetExecutingAssembly());
            var container = IoC.AutoFac.Configurator.Container;
            /* attach mvc resolver */
            IDependencyResolver resolver = new AutofacDependencyResolver(container);
            var signalRResolver          = new Autofac.Integration.SignalR.AutofacDependencyResolver(container);

            DependencyResolver.SetResolver(resolver);
            GlobalHost.DependencyResolver = signalRResolver;
            var config = new HubConfiguration {
                Resolver = signalRResolver
            };

            app.MapSignalR("/signalr", config);
        }
Пример #4
0
        public void Configuration(IAppBuilder app)
        {
            //Configure AutoMapper (http://automapper.codeplex.com/)
            Mapper.Initialize(ConfigureMapper);

            //Configure Bearer Authentication
            OAuthOptions = new OAuthAuthorizationServerOptions();
            app.UseOAuthBearerTokens(OAuthOptions);

            //Configure AutoFac for DependencyResolver (http://autofac.org/)
            IContainer container          = RegisterServices();
            var        resolverForSignalr = new Autofac.Integration.SignalR.AutofacDependencyResolver(container);
            var        resolver           = new App.Common.AutoFacDependencyResolver(container);

            //Configure WebApi
            var config = new HttpConfiguration()
            {
                DependencyResolver = resolver
            };

            ConfigureWebApi(config);
            app.UseWebApi(config);

            //Configure SignalR self host
            var hubConfiguration = new HubConfiguration()
            {
                Resolver = resolverForSignalr
            };

            app.MapSignalR(hubConfiguration);

            //Log trafic using Log4Net
            app.Use(typeof(Logging));

            // container.Resolve<IRavenRepository>();

            //Set global dependency resolver for signalr
            GlobalHost.DependencyResolver = resolverForSignalr;
        }
        /// <summary>
        /// The application_ start.
        /// </summary>
        protected void Application_Start()
        {
            AppDomain.CurrentDomain.SetData(
                "DataDirectory",
                @"E:\BSUIR\_Fourth_Year\7-th_term\TermWork\BSUIR.TermWork.ImageViewer");
            var mvcContainerBuilder = new MvcContainerBuilder();
            mvcContainerBuilder.RegisterComponents();
            var f = mvcContainerBuilder.ContainerBuilder.Build();
            var dependencyResolver =
                new AutofacDependencyResolver(f);
            DependencyResolver.SetResolver(dependencyResolver);

            var signalRContainerBuilder = new SignalRContainerBuilder();
            var signalRDependencyResolver =
                new Autofac.Integration.SignalR.AutofacDependencyResolver(
                    f);
            GlobalHost.DependencyResolver = signalRDependencyResolver;

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }