Пример #1
0
        public void ResolveDependencies(IList <CodeUnit> resolvedUnits = null)
        {
            if (resolvedUnits == null)
            {
                resolvedUnits = new List <CodeUnit>();
            }

            var reader = SourceCodeReader.GetReaderFor(CurrentDependency);

            CodeLines = reader.ReadLines();

            var dependencies = _parser.Parse(CodeLines);

            if (!IsNamespaceDependency && !IsLibrary)
            {
                dependencies.Add(_namespaceDependency);
            }

            foreach (var dependency in dependencies)
            {
                dependency.Path.MakePathAbsolute(CurrentDependency.Path.Directory);

                var resolved = resolvedUnits.FirstOrDefault(u => u.CurrentDependency.Path.Equals(dependency.Path));

                if (resolved != null)
                {
                    Dependencies.Add(resolved);
                }
                else
                {
                    var newUnit = new CodeUnit(dependency, _namespaceDependency, _parser, CurrentDependency.IsNamespaceDependency);

                    Dependencies.Add(newUnit);
                    resolvedUnits.Add(newUnit);

                    OnResolve(newUnit.CurrentDependency.Path.Path);

                    newUnit.ResolveDependencies(resolvedUnits);
                }
            }
        }
Пример #2
0
        private void GetNamespaceDependency()
        {
            var rootDependencies = _options
                                   .DependencyParser.Parse
                                   (
                SourceCodeReader
                .GetReaderFor(_options.RootDependency)
                .ReadLines()
                                   );

            var nsDependency = rootDependencies
                               .FirstOrDefault(d => d.IsNamespaceDependency);

            if (nsDependency == null)
            {
                throw new ArgumentException("No valid namespace defined in root.");
            }

            _namespaceDependency = nsDependency;
            _namespaceDependency.Path.MakePathAbsolute(_options.RootDependency.Path.Directory);
        }