private List<CollectionOverride> GetOverrides(JObject document) { var overrideList = new List<CollectionOverride>(); if (document["overrides"] != null) { overrideList = document["overrides"].Select( r => { var overObj = new CollectionOverride(); var prop = (JProperty)r; overObj.BundleId = prop.Name; var valObj = prop.Value as JObject; if (valObj != null) { overObj.Map = GetMap(prop.Value as JObject); overObj.Paths = GetPaths(prop.Value as JObject); overObj.Shim = GetShim(prop.Value as JObject); var bundledItems = valObj["bundledScripts"] as JArray; if (bundledItems != null) { overObj.BundledScripts = bundledItems.Select(x => x.ToString()).ToList(); } } return overObj; }) .ToList(); } return overrideList; }
private ConfigurationCollection ComposeCollection(List<Bundle> bundles) { var conf = new ConfigurationCollection(); conf.Overrides = new List<CollectionOverride>(); foreach (var bundle in bundles) { var scripts = bundle.Files.Select(r => PathHelpers.GetRequireRelativePath(EntryPoint, r.FileName)).ToList(); var paths = new RequirePaths { PathList = new List<RequirePath>() }; foreach (var script in scripts) { paths.PathList.Add(new RequirePath { Key = script, Value = PathHelpers.GetRequireRelativePath(EntryPoint, bundle.Output) }); } var over = new CollectionOverride { BundleId = bundle.BundleId, BundledScripts = scripts, Paths = paths }; conf.Overrides.Add(over); } return conf; }
private void ApplyOverride(ConfigurationCollection collection, CollectionOverride collOverride) { this.ApplyMapOverride(collection.Map, collOverride.Map); this.ApplyPathsOverride(collection.Paths, collOverride.Paths); this.ApplyShimOverride(collection.Shim, collOverride.Shim); }