Example #1
0
        public IDependency BuildDependency(Type contract, IDependencyEngine engine)
        {
            var genericArgs = contract.GenericTypeArguments;

            Type pipelineType;

            if (ExistsBehaviour(genericArgs, engine))
            {
                pipelineType = typeof(CommandFullPipeline <>);
            }
            else if (ExistsPreOrPostProcessor(genericArgs, engine))
            {
                pipelineType = typeof(CommandSequentialPipeline <>);
            }
            else
            {
                pipelineType = typeof(CommandSimplePipeline <>);
            }

            var implementation = pipelineType.MakeGenericType(genericArgs);
            var lifetime       = engine.DefineLifetime(implementation);
            var resolver       = DependencyResolver.Build(lifetime, implementation);

            return(Dependency.Build(lifetime, new[] { contract }, resolver));
        }
Example #2
0
        public IDependency BuildDependency(Type contract, IDependencyEngine engine)
        {
            var contracts = new[] { contract };

            if (_nullServicePredicate != null && _nullServicePredicate(engine))
            {
                return(new InstanceDependency(contracts, Activator.CreateInstance(_nullService)));
            }

            var lifetime = _lifetime ?? engine.DefineLifetime(_implementation);
            var resolver = DependencyResolver.Build(lifetime, _implementation);

            return(Dependency.Build(lifetime, contracts, resolver));
        }