internal void findInjectedFields(DependencyGatherer dependencies)
        {
            // Stupid. Can't believe I haven't fixed this in Baseline
            var list = new List <InjectedField>();

            dependencies.Variables.Each((key, _) =>
            {
                if (key is InjectedField)
                {
                    list.Add(key.As <InjectedField>());
                }
            });

            _method.Fields = list.ToArray();
        }
        protected Frame[] compileFrames(IList <Frame> frames)
        {
            // Step 1, resolve all the necessary variables
            foreach (var frame in frames)
            {
                frame.ResolveVariables(this);
            }

            // Step 1a;) -- figure out if you can switch to inline service
            // creation instead of the container.
            var services = frames.SelectMany(x => x.Uses).OfType <ServiceVariable>().ToArray();

            if (services.Any() && services.All(x => x.CanBeReduced))
            {
                AllKnownBuildSteps.GroupBy(x => x.ServiceType).Where(x => x.Count() > 1).Each(group =>
                {
                    var index = 0;
                    group.Reverse().Each(step =>
                    {
                        step.Number = ++index;
                    });
                });

                foreach (var service in services)
                {
                    service.UseInlinePlan();
                }
            }

            // Step 2, calculate dependencies
            var dependencies = new DependencyGatherer(this, frames);

            findInjectedFields(dependencies);

            // Step 3, gather any missing frames and
            // add to the beginning of the list
            dependencies.Dependencies.GetAll().SelectMany(x => x).Distinct()
            .Where(x => !frames.Contains(x))
            .Each(x => frames.Insert(0, x));

            // Step 4, topological sort in dependency order
            return(frames.TopologicalSort(x => dependencies.Dependencies[x], true).ToArray());
        }
        protected Frame[] compileFrames(IList <Frame> frames)
        {
            // Step 1, resolve all the necessary variables
            foreach (var frame in frames)
            {
                frame.ResolveVariables(this);
            }

            // Step 2, calculate dependencies
            var dependencies = new DependencyGatherer(this, frames);

            findInjectedFields(dependencies);

            // Step 3, gather any missing frames and
            // add to the beginning of the list
            dependencies.Dependencies.GetAll().SelectMany(x => x).Distinct()
            .Where(x => !frames.Contains(x))
            .Each(x => frames.Insert(0, x));

            // Step 4, topological sort in dependency order
            return(frames.TopologicalSort(x => dependencies.Dependencies[x], true).ToArray());
        }