public void RegisterThrowsIfAssemblyAlreadyRegistered() { // Arrange var part = new ApplicationPart(BuildAssembly(), "~/mymodule"); var dictionary = new DictionaryBasedVirtualPathFactory(); var registry = new ApplicationPartRegistry(dictionary); Func <object> myFunc = () => "foo"; // Act registry.Register(part, myFunc); // Assert Assert.Throws <InvalidOperationException>(() => registry.Register(part, myFunc), String.Format("The assembly \"{0}\" is already registered.", part.Assembly.ToString())); }
public void RegisterThrowsIfPathAlreadyRegistered() { // Arrange var part = new ApplicationPart(BuildAssembly(), "~/mymodule"); var dictionary = new DictionaryBasedVirtualPathFactory(); var registry = new ApplicationPartRegistry(dictionary); Func <object> myFunc = () => "foo"; // Act registry.Register(part, myFunc); // Assert var newPart = new ApplicationPart(BuildAssembly("different-assembly"), "~/mymodule"); Assert.Throws <InvalidOperationException>(() => registry.Register(newPart, myFunc), "An application module is already registered for virtual path \"~/mymodule/\"."); }
// REVIEW: Do we need an Unregister? // Register an assembly as an application module, which makes its compiled web pages // and embedded resources available public static void Register(ApplicationPart applicationPart) { // Ensure the registry is ready and the route handlers are set up _initApplicationPart.EnsurePerformed(); Debug.Assert(_partRegistry != null, "Part registry should be initialized"); _partRegistry.Register(applicationPart); }
public static void Initialize() { foreach (var module in PluginManager.Current.Modules.Keys) { var assembly = PluginManager.Current.Modules[module]; ApplicationPartRegistry.Register(PluginManager.Current.Modules[module]); module.Install(); var container = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <Castle.Windsor.IWindsorContainer>(); container.Register(Castle.MicroKernel.Registration.AllTypes.Of <System.Web.Mvc.IController>().FromAssembly(assembly).LifestyleTransient()); } }
public override void RegisterArea(AreaRegistrationContext context) { ApplicationPartRegistry.Register(this.GetType().Assembly, "~/Areas/Security/"); context.MapRoute("security_default", "Security/{controller}/{action}/{id}", new { controller = "Home", action = "index", id = "" }, new [] { typeof(AccountController).Namespace }); context.MapRoute( "OpenIdDiscover", "Security/Auth/Discover"); }
public void ApplicationPartRegistryLooksUpPartsByAssembly() { // Arrange var assembly = BuildAssembly(); var part = new ApplicationPart(assembly, "~/mymodule"); var dictionary = new DictionaryBasedVirtualPathFactory(); var registry = new ApplicationPartRegistry(dictionary); Func <object> myFunc = () => "foo"; // Act registry.Register(part, myFunc); // Assert Assert.Equal(registry[assembly], part); }
public void ApplicationPartRegistryLooksUpPartsByName() { // Arrange var part = new ApplicationPart(BuildAssembly(), "~/mymodule"); var dictionary = new DictionaryBasedVirtualPathFactory(); var registry = new ApplicationPartRegistry(dictionary); Func <object> myFunc = () => "foo"; // Act registry.Register(part, myFunc); // Assert Assert.AreEqual(registry["my-assembly"], part); Assert.AreEqual(registry["MY-aSSembly"], part); }
public void RegisterCreatesRoutesForValidPages() { // Arrange var part = new ApplicationPart(BuildAssembly(), "~/mymodule"); var dictionary = new DictionaryBasedVirtualPathFactory(); var registry = new ApplicationPartRegistry(dictionary); Func <object> myFunc = () => "foo"; // Act registry.Register(part, myFunc); // Assert Assert.True(dictionary.Exists("~/mymodule/Page1")); Assert.Equal(dictionary.CreateInstance("~/mymodule/Page1"), "foo"); Assert.False(dictionary.Exists("~/mymodule/Page2")); Assert.False(dictionary.Exists("~/mymodule/Page3")); }
protected void Application_Start() { Trace.WriteLine("Application_Start called."); ApplicationPartRegistry.Register(typeof(UrdmsApplication).Assembly); var connectionString = ConfigurationManager.ConnectionStrings["Database"].ConnectionString; AreaRegistration.RegisterAllAreas(); AppRoutes.Register(RouteTable.Routes); RegisterDefaultRoutes(RouteTable.Routes); RegisterDependencies(builder => { builder.RegisterType <UrdmsRoleProvider>().As <IRoleProvider>(); builder.RegisterType <LibGuideService>().As <ILibGuideService>(); builder.RegisterType <SimpleWebRequestService>().As <ISimpleWebRequestService>(); builder.RegisterType <AppSettingsService>().As <IAppSettingsService>(); builder.RegisterType <CsvHelper>().As <ICsvHelper>(); builder.RegisterModule(new NHibernateModule { ConnectionString = connectionString }); builder.RegisterModule(new DataAccessModule()); builder.RegisterModule(new NServiceBusModule()); builder.RegisterType <DummyMembershipService>().As <IMembershipService>(); // TODO: Put your user service implementation here builder.RegisterType <DummyDirectoryEntryService>().As <IDirectoryEntryService>(); // TODO: Put your user service implementation here builder.RegisterModule(new UserServiceModule()); }); FilterProviders.Providers.Add(new FilterProvider()); ModelBinderProviders.BinderProviders.Add(new AppModelBinderProvider()); Trace.WriteLine("Updating database."); Migrations.UpdateDatabase(connectionString, typeof(App).Assembly); Trace.WriteLine("Application_Start ended."); }