private void TryParseConfiguration() { if (!File.Exists(_configPath)) { return; } using (var stream = File.OpenText(_configPath)) { var reader = new JsonTextReader(stream); _jsonObject = JObject.Load(reader); JToken token; if (_jsonObject.TryGetValue(_packagesTag, out token)) { var builder = new PackageGraphBuilder(); foreach (var package in token.Children()) { var packageProp = (JProperty)package; var packageObject = (JObject)packageProp.Value; var packageId = new PackageId(packageProp.Name); var info = new ProductPackageInfo(); if (packageObject.TryGetValue(_packageTag, out token)) { var packageConfigObject = (JObject)token; info.Configuration = new PackageConfiguration(packageId, packageConfigObject); if (packageObject.TryGetValue(_filesTag, out token) && token.HasValues) { var array = (JArray)token; info.Files.AddRange(array.Select(x => x.ToString())); } List <PackageId> dependencies = new List <PackageId>(); if (packageObject.TryGetValue(_dependenciesTag, out token) && token.HasValues) { var array = (JArray)token; dependencies.AddRange(array.Select(x => new PackageId(x.ToString()))); } builder.Append(packageId, dependencies); ProductPackages.Add(info); } } Packages = builder.Build(); IsProductConfigured = true; } } }
public void SetPackageConfiguration(IPackageConfiguration packageConfiguration, IEnumerable <string> files, IEnumerable <string> dependencies) { RemovePackageConfiguration(packageConfiguration.Id); Packages.Add(packageConfiguration); var info = new ProductPackageInfo(); info.Files.AddRange(files); info.Dependencies.AddRange(dependencies); ProductPackagesInfo.Add(packageConfiguration.Id.ToString(), info); }
public void Reconfigure(IEnumerable <IPackageConfiguration> packages, IPackageGraph packageGraph, IDictionary <PackageId, IEnumerable <string> > files) { Packages = packageGraph; ProductPackages.Clear(); foreach (var package in packages) { var info = new ProductPackageInfo { Configuration = package }; var packageFiles = files.FirstOrDefault(f => f.Key.IsSamePackage(package.Id)).Value; if (packageFiles != null) { info.Files.AddRange(packageFiles); } ProductPackages.Add(info); } }