Example #1
0
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();

            WebApiConfig.Register(config);
            StructureMapConfig.RegisterResolver(config);

            //TODO: make this more secure i.e. http://localhost:4200
            var cors = new EnableCorsAttribute("http://localhost:4200", "*", "*");

            config.EnableCors(cors);

            var identityServerUrl = ConfigurationManager.AppSettings.Get("identityServerUrl");

            app.UseIdentityServerBearerTokenAuthentication(new IdentityServer3.AccessTokenValidation.IdentityServerBearerTokenAuthenticationOptions
            {
                AuthenticationMode = AuthenticationMode.Active,
                Authority          = identityServerUrl,
                RequiredScopes     = new[] { "phonebookAPI.read", "phonebookAPI.write" }
            });

            app.UseWebApi(config);

            app.Run(context =>
            {
                context.Response.ContentType = "text/plain";
                return(context.Response.WriteAsync("Hello, world."));
            });
        }
    public static IServiceProvider ConfigureIoc(this IServiceCollection services)
    {
        var container = StructureMapConfig.RegisterComponents();

        container.Configure(config =>
        {
            //////config.ForSingletonOf<IHttpContextAccessor>().Use<HttpContextAccessor>();
            //////// Identity services
            ////////config.ForSingletonOf<IdentityMarkerService>();
            //////config.For<IUserValidator<IdentityUserViewModel>>().Use<UserValidator<IdentityUserViewModel>>();
            //////config.For<IPasswordValidator<IdentityUserViewModel>>().Use<PasswordValidator<IdentityUserViewModel>>();
            //////config.For<IPasswordHasher<IdentityUserViewModel>>().Use<PasswordHasher<IdentityUserViewModel>>();
            //////config.For<IOptions<IdentityOptions>>().Use<OptionsAccessor>();

            //////config.For<ILookupNormalizer>().Use<UpperInvariantLookupNormalizer>();
            //////config.For<IRoleValidator<IdentityRoleViewModel>>().Use<RoleValidator<IdentityRoleViewModel>>();
            //////// No interface for the error describer so we can add errors without rev'ing the interface
            //////config.For<IdentityErrorDescriber>();
            //////config.For<ISecurityStampValidator>().Use<SecurityStampValidator<IdentityUserViewModel>>();
            //////config.For<IUserClaimsPrincipalFactory<IdentityUserViewModel>>().Use<UserClaimsPrincipalFactory <IdentityUserViewModel, IdentityRoleViewModel>>();
            //////config.For<UserManager<IdentityUserViewModel>>().Use<UserManager<IdentityUserViewModel>>();
            //////config.For<SignInManager<IdentityUserViewModel>>().Use<SignInManager<IdentityUserViewModel>>();
            //////config.For<RoleManager<IdentityRoleViewModel>>().Use<RoleManager<IdentityRoleViewModel>>();
            config.Populate(services);
        });
        return(container.GetInstance <IServiceProvider>());
    }
Example #3
0
        public static IContainer Initialize()
        {
            //return new Container(c => c.AddRegistry<DefaultRegistry>());
            var container = StructureMapConfig.RegisterComponents();

            container.Configure(o => o.AddRegistry <DefaultRegistry>());
            return(container);
        }
Example #4
0
 public static void Start()
 {
     StructureMapDependencyScope = new StructureMapDependencyScope(StructureMapConfig.InitMvc());
     //IContainer container = IoC.Initialize();
     //StructureMapDependencyScope = new StructureMapDependencyScope(container);
     DependencyResolver.SetResolver(StructureMapDependencyScope);
     DynamicModuleUtility.RegisterModule(typeof(StructureMapScopeModule));
 }
Example #5
0
        public void TestMethod1()
        {
            StructureMapConfig.Configure();

            var controller = new HealthCheckController();// IoC.Container);
            var result     = controller.Get() as OkNegotiatedContentResult <HealthCheckResponse>;

            Assert.IsFalse(result.Content.errors.Any());
        }
Example #6
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            FluentNhibernateConfig.CreateConfig();
            StructureMapConfig.Register(FluentNhibernateConfig.SessionFactory);
            NHibernateProfilerBootstrapper.PreStart();
        }
Example #7
0
 protected void Application_Start(object sender, EventArgs e)
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     StructureMapConfig.Register();
     GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
 }
Example #8
0
        private static void SetUpIoC()
        {
            var container = StructureMapConfig.ConfigureDependencies();

            GlobalConfiguration.Configuration.DependencyResolver = new StructureMapDependencyResolver(container);
        }
Example #9
0
 public static void Start()
 {
     StructureMapConfig.SetupContainer();
 }
Example #10
0
 public static void End()
 {
     StructureMapConfig.DisposeContainer();
 }