Example #1
0
 protected virtual void OverrideServices(FluentRegistration pandora, DotlessConfiguration configuration)
 {
     if (configuration.Logger != null)
     {
         pandora.Service <ILogger>().Implementor(configuration.Logger);
     }
 }
Example #2
0
        private void RegisterWebServices(FluentRegistration pandora, CoffeeScriptConfiguration configuration)
        {
            pandora.Service <IHttp>()
            .Implementor <Http>().Lifestyle.Transient();

            pandora.Service <CoffeeHandlerImpl>()
            .Implementor <CoffeeHandlerImpl>().Lifestyle.Transient();

            pandora.Service <IParameterSource>()
            .Implementor <QueryStringParameterSource>().Lifestyle.Transient();

            if (configuration.CacheEnabled)
            {
                pandora.Service <IResponse>()
                .Implementor <CachedJavascriptResponse>().Lifestyle.Transient();
            }
            else
            {
                pandora.Service <IResponse>()
                .Implementor <JavascriptResponse>().Lifestyle.Transient();
            }

            pandora.Service <ICache>()
            .Implementor <HttpCache>().Lifestyle.Transient();

            pandora.Service <ILogger>()
            .Implementor <AspResponseLogger>()
            .Parameters("level").Set("error-level")
            .Lifestyle.Transient();

            pandora.Service <IPathResolver>()
            .Implementor <AspServerPathResolver>().Lifestyle.Transient();
        }
Example #3
0
 protected virtual void RegisterLocalServices(FluentRegistration pandora)
 {
     pandora.Service <ICache>().Implementor <InMemoryCache>();
     pandora.Service <IParameterSource>().Implementor <ConsoleArgumentParameterSource>();
     pandora.Service <ILogger>().Implementor <ConsoleLogger>().Parameters("level").Set("error-level");
     pandora.Service <IPathResolver>().Implementor <RelativePathResolver>();
 }
Example #4
0
        public virtual void Register(Action <FluentRegistration> registrationClosure)
        {
            var registration = new FluentRegistration(this);

            registrationClosure(registration);
            registration.Commit();
        }
 protected override void RegisterParameterSource(FluentRegistration pandora, DotlessConfiguration configuration)
 {
     if (!configuration.DisableParameters)
     {
         pandora.Service <IParameterSource>().Implementor <QueryStringParameterSource>().Lifestyle.Transient();
     }
 }
 protected override void RegisterParameterSource(FluentRegistration pandora, DotlessConfiguration configuration)
 {
     if (!configuration.DisableParameters)
     {
         pandora.Service<IParameterSource>().Implementor<QueryStringParameterSource>().Lifestyle.Transient();
     }
 }
Example #7
0
        private void RegisterCoreServices(FluentRegistration pandora, CoffeeScriptConfiguration configuration)
        {
            pandora.Service<string>("compiler-path")
                .Instance(configuration.CompilerPath);

            pandora.Service<LogLevel>("error-level")
                .Instance(configuration.LogLevel);

            pandora.Service<string>("compiler-args")
                .Instance(configuration.CompilePattern);

            if (configuration.CacheEnabled)
                pandora.Service<ICoffeeEngine>()
                    .Implementor<CoffeeCacheDecorator>().Lifestyle.Transient();

            pandora.Service<ICoffeeEngine>()
                .Implementor<CoffeeEngine>()
                    .Parameters("compilerPath").Set("compiler-path")
                    .Parameters("compilerArguments").Set("compiler-args")
                .Lifestyle.Transient();

            //pandora.Service<bool>("minify-output").Instance(configuration.MinifyOutput);

            pandora.Service<IFileReader>()
                .Implementor(configuration.LessSource);
        }
Example #8
0
        private void RegisterCoreServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            pandora.Service<LogLevel>("error-level")
                .Instance(configuration.LogLevel);

            pandora.Service<int>("default-optimization")
                .Instance(configuration.Optimization);

            pandora.Service<bool>("minify-output")
                .Instance(configuration.MinifyOutput);

            pandora.Service<IStylizer>()
                .Implementor<PlainStylizer>();

            pandora.Service<Parser.Parser>()
                .Implementor<Parser.Parser>()
                    .Parameters("optimization").Set("default-optimization")
                .Lifestyle.Transient();

            pandora.Service<ILessEngine>()
                .Implementor<ParameterDecorator>().Lifestyle.Transient();

            if (configuration.CacheEnabled)
                pandora.Service<ILessEngine>()
                    .Implementor<CacheDecorator>().Lifestyle.Transient();

            pandora.Service<ILessEngine>()
                .Implementor<LessEngine>()
                    .Parameters("compress").Set("minify-output")
                .Lifestyle.Transient();

            pandora.Service<IFileReader>()
                .Implementor(configuration.LessSource);
        }
Example #9
0
        private void RegisterCoreServices(FluentRegistration pandora, CoffeeScriptConfiguration configuration)
        {
            pandora.Service <string>("compiler-path")
            .Instance(configuration.CompilerPath);

            pandora.Service <LogLevel>("error-level")
            .Instance(configuration.LogLevel);

            pandora.Service <string>("compiler-args")
            .Instance(configuration.CompilePattern);

            if (configuration.CacheEnabled)
            {
                pandora.Service <ICoffeeEngine>()
                .Implementor <CoffeeCacheDecorator>().Lifestyle.Transient();
            }

            pandora.Service <ICoffeeEngine>()
            .Implementor <CoffeeEngine>()
            .Parameters("compilerPath").Set("compiler-path")
            .Parameters("compilerArguments").Set("compiler-args")
            .Lifestyle.Transient();

            //pandora.Service<bool>("minify-output").Instance(configuration.MinifyOutput);

            pandora.Service <IFileReader>()
            .Implementor(configuration.LessSource);
        }
Example #10
0
        private void RegisterWebServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            pandora.Service <IClock>().Implementor <Clock>().Lifestyle.Transient();
            pandora.Service <IHttp>().Implementor <Http>().Lifestyle.Transient();
            pandora.Service <HandlerImpl>().Implementor <HandlerImpl>().Lifestyle.Transient();

            var responseService = configuration.CacheEnabled ?
                                  pandora.Service <IResponse>().Implementor <CachedCssResponse>() :
                                  pandora.Service <IResponse>().Implementor <CssResponse>();

            responseService.Parameters("isCompressionHandledByResponse").Set("default-is-compression-handled-by-response").Lifestyle.Transient();
            pandora.Service <bool>("default-is-compression-handled-by-response").Instance(configuration.HandleWebCompression);

            if (configuration.CacheEnabled)
            {
                responseService.Parameters("httpExpiryInMinutes").Set("http-expiry-in-minutes").Lifestyle.Transient();
                pandora.Service <int>("http-expiry-in-minutes").Instance(configuration.HttpExpiryInMinutes);
            }

            pandora.Service <ICache>().Implementor <HttpCache>().Lifestyle.Transient();
            pandora.Service <ILogger>().Implementor <AspResponseLogger>().Parameters("level").Set("error-level").Lifestyle.Transient();

            if (configuration.MapPathsToWeb)
            {
                pandora.Service <IPathResolver>().Implementor <AspServerPathResolver>().Lifestyle.Transient();
            }
            else
            {
                pandora.Service <IPathResolver>().Implementor <AspRelativePathResolver>().Lifestyle.Transient();
            }
        }
Example #11
0
        private void RegisterCoreServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            pandora.Service <LogLevel>("error-level").Instance(configuration.LogLevel);
            pandora.Service <IStylizer>().Implementor <PlainStylizer>();

            pandora.Service <IImporter>().Implementor <Importer>().Parameters("disableUrlRewriting").Set("default-disable-url-rewriting").Lifestyle.Transient();
            pandora.Service <bool>("default-disable-url-rewriting").Instance(configuration.DisableUrlRewriting);

            pandora.Service <Parser.Parser>().Implementor <Parser.Parser>().Parameters("optimization").Set("default-optimization").Lifestyle.Transient();
            pandora.Service <int>("default-optimization").Instance(configuration.Optimization);

            pandora.Service <ILessEngine>().Implementor <ParameterDecorator>().Lifestyle.Transient();

            if (configuration.CacheEnabled)
            {
                pandora.Service <ILessEngine>().Implementor <CacheDecorator>().Lifestyle.Transient();
            }

            pandora.Service <ILessEngine>().Implementor <LessEngine>().Parameters("compress").Set("minify-output").Lifestyle.Transient();
            pandora.Service <bool>("minify-output").Instance(configuration.MinifyOutput);

            pandora.Service <ILessEngine>().Implementor <LessEngine>().Parameters("plugins").Set("default-plugins").Lifestyle.Transient();
            pandora.Service <IEnumerable <IPluginConfigurator> >("default-plugins").Instance(configuration.Plugins);

            pandora.Service <IFileReader>().Implementor(configuration.LessSource);
        }
Example #12
0
 private void RegisterLocalServices(FluentRegistration pandora)
 {
     pandora.Service<ICache>().Implementor<InMemoryCache>();
     pandora.Service<IParameterSource>().Implementor<ConsoleArgumentParameterSource>();
     pandora.Service<ILogger>().Implementor<ConsoleLogger>().Parameters("level").Set("error-level");
     pandora.Service<IPathResolver>().Implementor<RelativePathResolver>();
 }
        private void RegisterWebServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            pandora.Service <IHttp>().Implementor <Http>().Lifestyle.Transient();
            pandora.Service <HandlerImpl>().Implementor <HandlerImpl>().Lifestyle.Transient();

            if (!configuration.DisableParameters)
            {
                pandora.Service <IParameterSource>().Implementor <QueryStringParameterSource>().Lifestyle.Transient();
            }

            var responseService = configuration.CacheEnabled ?
                                  pandora.Service <IResponse>().Implementor <CachedCssResponse>() :
                                  pandora.Service <IResponse>().Implementor <CssResponse>();

            responseService.Parameters("isCompressionHandledByResponse").Set("default-is-compression-handled-by-response").Lifestyle.Transient();
            pandora.Service <bool>("default-is-compression-handled-by-response").Instance(configuration.HandleWebCompression);

            pandora.Service <ICache>().Implementor <HttpCache>().Lifestyle.Transient();
            pandora.Service <ILogger>().Implementor <AspResponseLogger>().Parameters("level").Set("error-level").Lifestyle.Transient();

            if (configuration.MapPathsToWeb)
            {
                pandora.Service <IPathResolver>().Implementor <AspServerPathResolver>().Lifestyle.Transient();
            }
            else
            {
                pandora.Service <IPathResolver>().Implementor <AspRelativePathResolver>().Lifestyle.Transient();
            }
        }
Example #14
0
        protected virtual void RegisterCoreServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            pandora.Service<LogLevel>("error-level").Instance(configuration.LogLevel);
            pandora.Service<IStylizer>().Implementor<PlainStylizer>();

            var importer = pandora.Service<IImporter>().Implementor<Importer>();

            importer.Parameters("inlineCssFiles").Set("default-inline-css-files").Lifestyle.Transient();
            importer.Parameters("disableUrlRewriting").Set("default-disable-url-rewriting").Lifestyle.Transient();
            importer.Parameters("importAllFilesAsLess").Set("default-import-all-files-as-less").Lifestyle.Transient();

            pandora.Service<bool>("default-disable-url-rewriting").Instance(configuration.DisableUrlRewriting);
            pandora.Service<bool>("default-inline-css-files").Instance(configuration.InlineCssFiles);
            pandora.Service<bool>("default-import-all-files-as-less").Instance(configuration.ImportAllFilesAsLess);

            pandora.Service<Parser.Parser>().Implementor<Parser.Parser>().Parameters("optimization").Set("default-optimization").Lifestyle.Transient();
            pandora.Service<int>("default-optimization").Instance(configuration.Optimization);

            pandora.Service<ILessEngine>().Implementor<ParameterDecorator>().Lifestyle.Transient();

            if (configuration.CacheEnabled)
                pandora.Service<ILessEngine>().Implementor<CacheDecorator>().Lifestyle.Transient();

            pandora.Service<ILessEngine>().Implementor<LessEngine>().Parameters("compress").Set("minify-output").Lifestyle.Transient();
            pandora.Service<bool>("minify-output").Instance(configuration.MinifyOutput);

            pandora.Service<ILessEngine>().Implementor<LessEngine>().Parameters("plugins").Set("default-plugins").Lifestyle.Transient();
            pandora.Service<IEnumerable<IPluginConfigurator>>("default-plugins").Instance(configuration.Plugins);

            pandora.Service<IFileReader>().Implementor(configuration.LessSource);
        }
        private void RegisterWebServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            pandora.Service<IHttp>().Implementor<Http>().Lifestyle.Transient();
            pandora.Service<HandlerImpl>().Implementor<HandlerImpl>().Lifestyle.Transient();

            if (!configuration.DisableParameters)
            {
                pandora.Service<IParameterSource>().Implementor<QueryStringParameterSource>().Lifestyle.Transient();
            }

            var responseService = configuration.CacheEnabled ?
                pandora.Service<IResponse>().Implementor<CachedCssResponse>() :
                pandora.Service<IResponse>().Implementor<CssResponse>();
            pandora.Service<IClock>().Implementor<Clock>();

            responseService.Parameters("isCompressionHandledByResponse").Set("default-is-compression-handled-by-response").Lifestyle.Transient();
            pandora.Service<bool>("default-is-compression-handled-by-response").Instance(configuration.HandleWebCompression);

            if (configuration.CacheEnabled)
            {
                responseService.Parameters("httpExpiryInMinutes").Set("http-expiry-in-minutes").Lifestyle.Transient();
                pandora.Service<int>("http-expiry-in-minutes").Instance(configuration.HttpExpiryInMinutes);
            }

            pandora.Service<ICache>().Implementor<HttpCache>().Lifestyle.Transient();
            pandora.Service<ILogger>().Implementor<AspResponseLogger>().Parameters("level").Set("error-level").Lifestyle.Transient();

            if (configuration.MapPathsToWeb)
                pandora.Service<IPathResolver>().Implementor<AspServerPathResolver>().Lifestyle.Transient();
            else
                pandora.Service<IPathResolver>().Implementor<AspRelativePathResolver>().Lifestyle.Transient();
        }
Example #16
0
        private void RegisterServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            OverrideServices(pandora, configuration);

            RegisterLocalServices(pandora);

            RegisterCoreServices(pandora, configuration);
        }
Example #17
0
        private void RegisterServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            OverrideServices(pandora, configuration);

            RegisterLocalServices(pandora);

            RegisterCoreServices(pandora, configuration);
        }
Example #18
0
        private void RegisterServices(FluentRegistration pandora, CoffeeScriptConfiguration configuration)
        {
            OverrideServices(pandora, configuration);

            RegisterWebServices(pandora, configuration);

            RegisterCoreServices(pandora, configuration);
        }
Example #19
0
        protected override void RegisterServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            base.RegisterServices(pandora, configuration);

            RegisterParameterSource(pandora, configuration);

            RegisterWebServices(pandora, configuration);
        }
        protected override void RegisterServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            base.RegisterServices(pandora, configuration);

            RegisterParameterSource(pandora, configuration);

            RegisterWebServices(pandora, configuration);
        }
Example #21
0
        protected virtual void RegisterServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            OverrideServices(pandora, configuration);

            if (!configuration.Web)
                RegisterLocalServices(pandora);

            RegisterCoreServices(pandora, configuration);
        }
Example #22
0
        protected virtual void RegisterServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            OverrideServices(pandora, configuration);

            if (!configuration.Web)
            {
                RegisterLocalServices(pandora);
            }

            RegisterCoreServices(pandora, configuration);
        }
Example #23
0
        protected virtual void RegisterCoreServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            pandora.Service <LogLevel>("error-level").Instance(configuration.LogLevel);
            pandora.Service <IStylizer>().Implementor <PlainStylizer>();

            var importer = pandora.Service <IImporter>().Implementor <Importer>();

            importer.Parameters("inlineCssFiles").Set("default-inline-css-files").Lifestyle.Transient();
            importer.Parameters("disableUrlRewriting").Set("default-disable-url-rewriting").Lifestyle.Transient();
            importer.Parameters("rootPath").Set("default-root-path").Lifestyle.Transient();
            importer.Parameters("importAllFilesAsLess").Set("default-import-all-files-as-less").Lifestyle.Transient();

            pandora.Service <bool>("default-disable-url-rewriting").Instance(configuration.DisableUrlRewriting);
            pandora.Service <string>("default-root-path").Instance(configuration.RootPath);
            pandora.Service <bool>("default-inline-css-files").Instance(configuration.InlineCssFiles);
            pandora.Service <bool>("default-import-all-files-as-less").Instance(configuration.ImportAllFilesAsLess);

            pandora.Service <Parser.Parser>().Implementor <Parser.Parser>().Parameters("optimization").Set("default-optimization").Lifestyle.Transient();
            pandora.Service <int>("default-optimization").Instance(configuration.Optimization);

            if (!configuration.DisableParameters)
            {
                pandora.Service <ILessEngine>().Implementor <ParameterDecorator>().Lifestyle.Transient();
            }

            if (configuration.CacheEnabled)
            {
                pandora.Service <ILessEngine>().Implementor <CacheDecorator>().Lifestyle.Transient();
            }

            pandora.Service <ILessEngine>().Implementor <LessEngine>()
            .Parameters("compress").Set("minify-output")
            .Parameters("keepFirstSpecialComment").Set("keepFirstSpecialComment")
            .Parameters("debug").Set("debug")
            .Parameters("disableVariableRedefines").Set("disableVariableRedefines")
            .Parameters("disableColorCompression").Set("disableColorCompression")
            .Parameters("strictMath").Set("strictMath")
            .Lifestyle.Transient();
            pandora.Service <bool>("minify-output").Instance(configuration.MinifyOutput);
            pandora.Service <bool>("debug").Instance(configuration.Debug);
            pandora.Service <bool>("disableVariableRedefines").Instance(configuration.DisableVariableRedefines);
            pandora.Service <bool>("disableColorCompression").Instance(configuration.DisableColorCompression);
            pandora.Service <bool>("strictMath").Instance(configuration.StrictMath);
            pandora.Service <bool>("keepFirstSpecialComment").Instance(configuration.KeepFirstSpecialComment);

            pandora.Service <ILessEngine>().Implementor <LessEngine>().Parameters("plugins").Set("default-plugins").Lifestyle.Transient();
            pandora.Service <IEnumerable <IPluginConfigurator> >("default-plugins").Instance(configuration.Plugins);

            pandora.Service <IFileReader>().Implementor(configuration.LessSource);
        }
        /// <summary>
        /// Gets a registration for some contract type.
        /// </summary>
        /// <param name="contractType">The contract type.</param>
        /// <param name="container">The container.</param>
        /// <returns><value>The registration item</value> if this source can handle it, otherwise <value>null</value>.</returns>
        public RegistrationItem GetRegistrationFor(Type contractType, IContainer container)
        {
            Type[] genericArguments = contractType.GetGenericArguments();

            // Try get the Registration for the open generic type.
            RegistrationItem openGenericTypeRegistration = null;

            _registrationContainer.TryGetRegistration(contractType.GetGenericTypeDefinition(), out openGenericTypeRegistration);

            if (openGenericTypeRegistration == null)
            {
                throw new RegistrationNotFoundException(string.Format(Resources.RegistrationNotFoundFormat,
                                                                      contractType.GetGenericTypeDefinition()),
                                                        contractType.GetGenericTypeDefinition());
            }

            // Try to find a closed generic which passes the open signature.
            var registrationItem = _registrationContainer
                                   .GetRegistration(registration => contractType.IsAssignableFrom(registration.ImplementationType));

            Type implementationType = null;

            if (registrationItem != null)
            {
                implementationType = registrationItem.ImplementationType;
            }

            // RegisterInstance closed generic type on-the-fly, if no match until now.
            if (implementationType == null)
            {
                implementationType = openGenericTypeRegistration.ImplementationType.MakeGenericType(genericArguments);
            }

            var closedGenericRegistration = new RegistrationItem(contractType)
            {
                Activator = new ReflectionActivator(
                    implementationType,
                    container.Resolve <IConstructorSelector>(),
                    container.Resolve <IArgumentCollector>()
                    ),
                ImplementationType = implementationType
            };

            var fluentRegistration = new FluentRegistration(closedGenericRegistration);

            fluentRegistration.ControlledBy(openGenericTypeRegistration.Lifecycle.GetType());

            return(closedGenericRegistration);
        }
 public void Execute(FluentRegistration registration)
 {
     var types = FromAssembly.GetTypes();
     foreach (var type in types)
     {
         if (type.IsInterface) continue;
         if (type.IsAbstract) continue;
         var typeRegistration = new Registration
                                    {
                                        Service = type,
                                        Implementor = type,
                                    };
         registration.store.AddRegistration(typeRegistration);
     }
 }
Example #26
0
        private void RegisterServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            OverrideServices(pandora, configuration);

            if (configuration.Web)
            {
                RegisterWebServices(pandora, configuration);
            }
            else
            {
                RegisterLocalServices(pandora);
            }

            RegisterCoreServices(pandora, configuration);
        }
        private void RegisterWebServices(FluentRegistration pandora)
        {
            pandora.Service<HttpContextBase>().Instance(_context);
            pandora.Service<IHttp>().Implementor<Http>();
            pandora.Service<IFileReader>().Implementor<VirtualFileReader>();
            pandora.Service<VirtualPathProvider>().Instance(_virtualPathProvider);

            //if (!configuration.DisableParameters)
            //{
            //    pandora.Service<IParameterSource>().Implementor<QueryStringParameterSource>().Lifestyle.Transient();
            //}

            pandora.Service<ICache>().Implementor<HttpCache>().Lifestyle.Transient();
            pandora.Service<ILogger>().Instance(_logger);

            pandora.Service<IPathResolver>().Implementor<AspServerPathResolver>().Lifestyle.Transient();
        }
Example #28
0
        private void RegisterWebServices(FluentRegistration pandora, DotlessConfiguration configuration)
        {
            pandora.Service<IHttp>().Implementor<Http>().Lifestyle.Transient();
            pandora.Service<HandlerImpl>().Implementor<HandlerImpl>().Lifestyle.Transient();
            pandora.Service<IParameterSource>().Implementor<QueryStringParameterSource>().Lifestyle.Transient();

            if (configuration.CacheEnabled)
                pandora.Service<IResponse>().Implementor<CachedCssResponse>().Lifestyle.Transient();
            else
                pandora.Service<IResponse>().Implementor<CssResponse>().Lifestyle.Transient();

            pandora.Service<ICache>().Implementor<HttpCache>().Lifestyle.Transient();
            pandora.Service<ILogger>().Implementor<AspResponseLogger>().Parameters("level").Set("error-level").Lifestyle.Transient();

            if (configuration.MapPathsToWeb)
                pandora.Service<IPathResolver>().Implementor<AspServerPathResolver>().Lifestyle.Transient();
            else
                pandora.Service<IPathResolver>().Implementor<AspRelativePathResolver>().Lifestyle.Transient();
        }
Example #29
0
 protected virtual void OverrideServices(FluentRegistration pandora, DotlessConfiguration configuration)
 {
     if (configuration.Logger != null)
         pandora.Service<ILogger>().Implementor(configuration.Logger);
 }
 protected virtual void RegisterParameterSource(FluentRegistration pandora, DotlessConfiguration configuration)
 {
     pandora.Service<IParameterSource>().Implementor<NullParameterSource>().Lifestyle.Transient();
 }
Example #31
0
 protected virtual void RegisterParameterSource(FluentRegistration pandora, DotlessConfiguration configuration)
 {
     pandora.Service <IParameterSource>().Implementor <NullParameterSource>().Lifestyle.Transient();
 }
        /// <summary>
        /// Gets a registration for some contract type.
        /// </summary>
        /// <param name="contractType">The contract type.</param>
        /// <param name="container">The container.</param>
        /// <returns><value>The registration item</value> if this source can handle it, otherwise <value>null</value>.</returns>
        public RegistrationItem GetRegistrationFor(Type contractType, IContainer container)
        {
            Type[] genericArguments = contractType.GetGenericArguments();

            // Try get the Registration for the open generic type.
            RegistrationItem openGenericTypeRegistration = null;
            this._registrationContainer.TryGetRegistration(contractType.GetGenericTypeDefinition(), out openGenericTypeRegistration);

            if (openGenericTypeRegistration == null)
            {
                throw new RegistrationNotFoundException(string.Format(Resources.RegistrationNotFoundFormat,
                                                                      contractType.GetGenericTypeDefinition()),
                                                                      contractType.GetGenericTypeDefinition());
            }

            // Try to find a closed generic which passes the open signature.
            var registrationItem = this._registrationContainer
                .GetRegistration(registration => contractType.IsAssignableFrom(registration.ImplementationType));

            Type implementationType = null;

            if (registrationItem != null)
            {
                implementationType = registrationItem.ImplementationType;
            }

            // Register closed generic type on-the-fly, if no match until now.
            if (implementationType == null)
            {
                implementationType = openGenericTypeRegistration.ImplementationType.MakeGenericType(genericArguments);
            }

            var closedGenericRegistration = new RegistrationItem(contractType)
                                                {
                                                    Activator = new ReflectionActivator(
                                                        implementationType,
                                                        container.Resolve<IConstructorSelector>(),
                                                        container.Resolve<IArgumentCollector>()
                                                        ),
                                                    ImplementationType = implementationType
                                                };

            var fluentRegistration = new FluentRegistration(closedGenericRegistration);
            fluentRegistration.ControlledBy(openGenericTypeRegistration.Lifecycle.GetType());

            return closedGenericRegistration;
        }
 protected override void OverrideServices(FluentRegistration pandora, DotlessConfiguration configuration)
 {
     pandora.Service<ILogger>().Instance(logger);
     pandora.Service<IPathResolver>().Instance(pathResolver);
 }
        /// <summary>
        /// Gets a registration for some contract type.
        /// </summary>
        /// <param name="contractType">The contract type.</param>
        /// <param name="container">The container.</param>
        /// <returns><value>The registration item</value> if this source can handle it, otherwise <value>null</value>.</returns>
        public RegistrationItem GetRegistrationFor(Type contractType, IContainer container)
        {
            Type[] genericArguments = contractType.GetGenericArguments();

            // Get the Registration for the open generic type.
            RegistrationItem openGenericTypeRegistration =
                this._registrationContainer
                    .Registrations[contractType.GetGenericTypeDefinition()];

            // Register closed generic type on-the-fly.
            Type implementationType = openGenericTypeRegistration.ImplementationType.MakeGenericType(genericArguments);

            var closedGenericRegistration = new RegistrationItem(contractType)
                                                {
                                                    Activator = new ReflectionActivator(
                                                        implementationType,
                                                        container.Resolve<IConstructorSelector>(),
                                                        container.Resolve<IArgumentCollector>()
                                                        ),
                                                    ImplementationType = implementationType
                                                };

            var fluentRegistration = new FluentRegistration(closedGenericRegistration);
            fluentRegistration.ControlledBy(openGenericTypeRegistration.Lifecycle.GetType());

            return closedGenericRegistration;
        }
Example #35
0
        private void RegisterServices(FluentRegistration pandora, CoffeeScriptConfiguration configuration)
        {
            OverrideServices(pandora, configuration);

            RegisterWebServices(pandora, configuration);

            RegisterCoreServices(pandora, configuration);
        }
Example #36
0
        private void RegisterWebServices(FluentRegistration pandora, CoffeeScriptConfiguration configuration)
        {
            pandora.Service<IHttp>()
                .Implementor<Http>().Lifestyle.Transient();

            pandora.Service<CoffeeHandlerImpl>()
                .Implementor<CoffeeHandlerImpl>().Lifestyle.Transient();

            pandora.Service<IParameterSource>()
                .Implementor<QueryStringParameterSource>().Lifestyle.Transient();

            if (configuration.CacheEnabled)
                pandora.Service<IResponse>()
                    .Implementor<CachedJavascriptResponse>().Lifestyle.Transient();
            else
                pandora.Service<IResponse>()
                    .Implementor<JavascriptResponse>().Lifestyle.Transient();

            pandora.Service<ICache>()
                .Implementor<HttpCache>().Lifestyle.Transient();

            pandora.Service<ILogger>()
                .Implementor<AspResponseLogger>()
                    .Parameters("level").Set("error-level")
                .Lifestyle.Transient();

            pandora.Service<IPathResolver>()
                .Implementor<AspServerPathResolver>().Lifestyle.Transient();
        }
 public AutoConfiguration(FluentRegistration registration)
 {
     this.registration = registration;
 }