Beispiel #1
0
        public IProject Process(string filePath)
        {
            IXmlContentLoader loader = new XmlContentLoader(logger);

            loader.Load(filePath);

            if (!loader.IsSuccess)
            {
                return(null);
            }

            ProjectInfo info = ProcessProject(loader.Content, loader.FilePath);

            if (info == null)
            {
                return(null);
            }

            if (!info.IsNewFormat)
            {
                ProcessPackageConfig(info);
            }

            return(new Project(info.Path, info.Packages.ToImmutableDictionary()));
        }
Beispiel #2
0
        public IConfig Process(string filePath)
        {
            IXmlContentLoader loader = new XmlContentLoader(logger);

            loader.Load(filePath);

            if (!loader.IsSuccess)
            {
                return(null);
            }

            return(ProcessConfig(loader.Content, loader.FilePath));
        }
Beispiel #3
0
        private void ProcessPackageConfig(ProjectInfo info)
        {
            string directoryPath = Path.GetDirectoryName(info.Path);
            string configPath    = Path.Combine(directoryPath, PACKAGES_CONFIG_FILE_NAME);

            IXmlContentLoader loader = new XmlContentLoader(logger);

            loader.Load(configPath);

            if (!loader.IsSuccess)
            {
                return;
            }

            XElement root = loader.Content.Root;

            if (root == null || root.Name.LocalName != "packages")
            {
                return;
            }

            XNamespace xmlNamespace = root.GetDefaultNamespace();

            foreach (XElement elementPackage in root.Elements(xmlNamespace + "package"))
            {
                string packageId = (string)elementPackage.Attribute("id");
                string version   = GetValueFromElement(elementPackage, "version", xmlNamespace);

                if (string.IsNullOrWhiteSpace(packageId) ||
                    string.IsNullOrWhiteSpace(version))
                {
                    logger.Warn("Invalid package definition in " + PACKAGES_CONFIG_FILE_NAME + ".", loader.FilePath, elementPackage);
                    continue;
                }

                info.Packages[packageId] = new Package(packageId, version, CanBeUpdated(packageId, version));
            }
        }