Ejemplo n.º 1
0
        private BuildStep findStep(Type type)
        {
            // INSTEAD, let's pull all variable sources
            // If not a ServiceVariable, use the KnownVariableBuildStep, otherwise use the
            // parent build step and do NOT visit its dependencies
            var variable = _method.TryFindVariable(type, VariableSource.NotServices);

            if (variable != null)
            {
                return(new KnownVariableBuildStep(variable));
            }

            var @default = _graph.FindDefault(type);

            if (@default == null)
            {
                if (EnumerableStep.IsEnumerable(type))
                {
                    return(tryFillEnumerableOfAllKnown(type));
                }

                return(null);
            }

            return(findStep(@default));
        }
Ejemplo n.º 2
0
        private BuildStep findStep(Type type)
        {
            // INSTEAD, let's pull all variable sources
            // If not a ServiceVariable, use the KnownVariableBuildStep, otherwise use the
            // parent build step and do NOT visit its dependencies
            var variable = _method.TryFindVariable(type, VariableSource.NotServices);

            if (variable != null)
            {
                return(new KnownVariableBuildStep(variable));
            }

            var @default = _graph.FindDefault(type);

            if (@default?.ImplementationType != null)
            {
                var ctor = _graph.ChooseConstructor(@default.ImplementationType);
                if (ctor != null)
                {
                    return(new ConstructorBuildStep(type, @default.ImplementationType, @default.Lifetime, ctor));
                }
            }

            // TODO -- split on T[], IList<T>, IEnumerable<T>, IReadOnlyList<T>

            return(null);
        }
Ejemplo n.º 3
0
        private BuildStep findStep(Type type)
        {
            var variable = _method.TryFindVariable(type, VariableSource.All);

            if (variable != null)
            {
                return(new KnownVariableBuildStep(variable));
            }

            var @default = _graph.FindDefault(type);

            if (@default?.ImplementationType != null)
            {
                var ctor = _graph.ChooseConstructor(@default.ImplementationType);
                if (ctor != null)
                {
                    return(new ConstructorBuildStep(type, @default.ImplementationType, @default.Lifetime, ctor));
                }
            }

            // split on T[], IList<T>, IEnumerable<T>, IReadOnlyList<T>

            return(null);
        }