Inheritance: CassetteApplicationBase
Exemplo n.º 1
0
        static CassetteApplication CreateCassetteApplication()
        {
            lock (CreationLock)
            {
                var allConfigurations = GetAllConfigurations(GetCassetteConfigurationSection());
                var cacheVersion      = GetConfigurationVersion(allConfigurations, HttpRuntime.AppDomainAppVirtualPath);
                var settings          = new CassetteSettings(cacheVersion);
                var bundles           = new BundleCollection(settings);

                foreach (var configuration in allConfigurations)
                {
                    Trace.Source.TraceInformation("Executing configuration {0}",
                                                  configuration.GetType().AssemblyQualifiedName);
                    configuration.Configure(bundles, settings);
                }

                var routing = new CassetteRouting(settings.UrlModifier, () => ((CassetteApplication)CassetteApplicationContainer.Instance.Application).BundleContainer);
                settings.UrlGenerator = routing;

                Trace.Source.TraceInformation("Creating Cassette application object");
                Trace.Source.TraceInformation("IsDebuggingEnabled: {0}", settings.IsDebuggingEnabled);
                Trace.Source.TraceInformation("Cache version: {0}", cacheVersion);

                var application = new CassetteApplication(
                    bundles,
                    settings,
                    routing,
                    GetCurrentHttpContext
                    );

                application.InstallRoutes(RouteTable.Routes);

                return(application);
            }
        }
 CassetteApplication CreateApplication(Action<BundleCollection> configure, string sourceDirectory = "assets", bool isDebuggingEnabled = false)
 {
     var container = new Mock<ICassetteApplicationContainer<ICassetteApplication>>();
     var settings = new CassetteSettings("")
     {
         CacheDirectory = new IsolatedStorageDirectory(storage),
         SourceDirectory = new FileSystemDirectory(Path.GetFullPath(sourceDirectory)),
         UrlGenerator = new UrlGenerator(new VirtualDirectoryPrepender("/"), "_cassette"),
         IsDebuggingEnabled = isDebuggingEnabled
     };
     var bundles = new BundleCollection(settings);
     configure(bundles);
     foreach (var bundle in bundles)
     {
         bundle.Process(settings);
     }
     var bundleContainer = new BundleContainer(bundles);
     var application = new CassetteApplication(
         bundleContainer,
         settings,
         () => httpContext.Object
     );
     container.Setup(c => c.Application).Returns(() => application);
     new RouteInstaller(container.Object, "_cassette").InstallRoutes(routes);
     return application;
 }
Exemplo n.º 3
0
        CassetteApplication CreateApplication(Action<BundleCollection> configure)
        {
            var settings = new CassetteSettings("")
            {
                CacheDirectory = new IsolatedStorageDirectory(storage),
                SourceDirectory = new FileSystemDirectory(Path.GetFullPath("assets"))
            };
            var bundles = new BundleCollection(settings);
            configure(bundles);
            IBundleContainer bundleContainer = null;
            var application = new CassetteApplication(
                bundles,
                settings,
                new CassetteRouting(new VirtualDirectoryPrepender("/"), () => bundleContainer),
                () => httpContext.Object
            );
            bundleContainer = application.BundleContainer;

            application.InstallRoutes(routes);
            return application;
        }
Exemplo n.º 4
0
        static CassetteApplication CreateCassetteApplication()
        {
            lock (CreationLock)
            {
                var allConfigurations = GetAllConfigurations(GetCassetteConfigurationSection());
                var cacheVersion = GetConfigurationVersion(allConfigurations, HttpRuntime.AppDomainAppVirtualPath);
                var settings = new CassetteSettings();
                var bundles = new BundleCollection(settings);

                foreach (var configuration in allConfigurations)
                {
                    Trace.Source.TraceInformation("Executing configuration {0}",
                                                  configuration.GetType().AssemblyQualifiedName);
                    configuration.Configure(bundles, settings);
                }

                var routing = new CassetteRouting(settings.UrlModifier);
                settings.UrlGenerator = routing;

                Trace.Source.TraceInformation("Creating Cassette application object");
                Trace.Source.TraceInformation("IsDebuggingEnabled: {0}", settings.IsDebuggingEnabled);
                Trace.Source.TraceInformation("Cache version: {0}", cacheVersion);

                var application = new CassetteApplication(
                    bundles,
                    settings,
                    routing,
                    GetCurrentHttpContext,
                    cacheVersion
                    );

                if (_firstCreation)
                {
                    _firstCreation = false;
                    application.InstallRoutes(RouteTable.Routes);
                }

                return application;
            }
        }