Exemplo n.º 1
0
        private static ProjectConfig Parse(string json)
        {
            var config = JsonConvert.DeserializeObject <ProjectConfig>(json);

            if (config.SchemaVersion != "1.0")
            {
                throw new ApplicationException($"Unsupported config schema version '{config.SchemaVersion}'.");
            }

            config.Tags ??= Enumerable.Empty <string>();
            config.TargetFrameworks ??= Enumerable.Empty <TargetFrameworkConfig>();

            foreach (var targetFrameworkConfig in config.TargetFrameworks)
            {
                targetFrameworkConfig.Filter = TargetFrameworkNameFilter.Parse(targetFrameworkConfig.Name);

                foreach (var packageConfig in targetFrameworkConfig.Packages)
                {
                    packageConfig.NameFilter    = PackageNameFilter.Parse(packageConfig.Name);
                    packageConfig.VersionFilter = PackageVersionFilter.Parse(packageConfig.IgnoreVersion);
                }
            }

            return(config);
        }
Exemplo n.º 2
0
        public static PackageVersionFilter Parse(string s)
        {
            if (string.IsNullOrWhiteSpace(s))
            {
                throw new ApplicationException("Package version can't be empty.");
            }

            var filter = new PackageVersionFilter();

            if (TryParse(s, out filter._major, out filter._minor, out filter._patch))
            {
                return(filter);
            }

            throw new ApplicationException($"Invalid version '{s}'.");
        }