Beispiel #1
0
        private 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>());
                }
            });
            Fields = list.ToArray();
        }
Beispiel #2
0
        private 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(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());
        }