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 List <CollectionOverride> GetOverrides(JObject document) { var overrideList = new List <CollectionOverride>(); string parseSection = "overrides"; if (document[parseSection] != null) { JToken overridesParent = JsonParseOrThrow <JObject>(document[parseSection], parseSection, Path, null); overrideList = overridesParent.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); JArray bundledItems = JsonParseArrayOrThrow(valObj, "bundledScripts", parseSection, Path); 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) { Log?.LogMessage($" - Composing scripts for bundle {bundle.BundleId}"); 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) { var path = PathHelpers.GetRequireRelativePath(EntryPoint, bundle.Output); paths.PathList.Add(new RequirePath(script, path)); Log?.LogMessage($" - {script} -> {path}"); } 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); }