Beispiel #1
0
        protected void Application_Start()
        {
            /***Example of using Antler with StructureMap container & MongoDb . See connection string below***/

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new BlogViewEngine());

            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            var service = new BlogService();

            var container = new Container(x =>
            {
                x.For <IBlogService>().Use <BlogService>().Singleton();
                x.Scan(s =>
                {
                    s.AddAllTypesOf(typeof(BaseController));
                    s.Assembly("Blog.Web.Common");
                });
            });

            AntlerConfigurator = new AntlerConfigurator();
            AntlerConfigurator.UseStructureMapContainer(container)
            .UseStorage(MongoDbStorage.Use("mongodb://localhost:27017", "Antler")
                        .WithRecreatedDatabase(true).WithIdentityGenerator(() => new Random().Next(Int32.MinValue, Int32.MaxValue))).CreateInitialData(container.GetInstance <IBlogService>());

            ControllerBuilder.Current.SetControllerFactory(new BlogControllerFactory(t => Activator.CreateInstance(t, service)));
        }
Beispiel #2
0
            public void should_not_fail()
            {
                //act
                var configurator = new AntlerConfigurator();

                configurator.UseBuiltInContainer()
                .UseStorage(MongoDbStorage.Use("mongodb://localhost:27017", "AntlerTest")
                            .WithRecreatedDatabase(true));
            }
Beispiel #3
0
            public void SetUp()
            {
                Configurator = new AntlerConfigurator();

                Configurator.UseWindsorContainer()
                .UseStorage(MongoDbStorage.Use("mongodb://localhost:27017", "AntlerTest")
                            .WithRecreatedDatabase(true)
                            .WithIdentityGenerator(() => new Random().Next(1, int.MaxValue))
                            .WithEnsuredIndexes(MongoDbIndexBuilder.Add <Employee>(IndexKeys <Employee> .Ascending(_ => _.Id), IndexOptions <Employee> .SetUnique(true))
                                                .ThenAdd <Team>(IndexKeys <Team> .Ascending(_ => _.Id), IndexOptions <Employee> .SetUnique(true))));
            }