Exemple #1
0
        private RequirePaths GetPaths(JObject document)
        {
            var paths = new RequirePaths();

            paths.PathList = new List <RequirePath>();
            if (document != null && document["paths"] != null)
            {
                paths.PathList = document["paths"].Select(
                    r =>
                {
                    var result = new RequirePath();
                    var prop   = (JProperty)r;
                    result.Key = prop.Name;
                    if (prop.Value.Type == JTokenType.String)
                    {
                        result.Value = prop.Value.ToString();
                    }
                    else
                    {
                        var pathObj          = (JObject)prop.Value;
                        result.Value         = pathObj["path"].ToString();
                        result.DefaultBundle = pathObj["defaultBundle"].ToString();
                    }

                    return(result);
                }).ToList();
            }

            return(paths);
        }
        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 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);
        }
Exemple #4
0
        public XElement GetPaths(RequirePaths paths)
        {
            if (paths == null || !paths.PathList.Any())
            {
                return(null);
            }

            var pathsEl = new XElement("paths", paths.PathList.Select(r => new XElement("path", new XAttribute("key", r.Key), new XAttribute("value", r.Value))));

            return(pathsEl);
        }
        private RequirePaths GetPaths(JObject document)
        {
            var paths = new RequirePaths();

            paths.PathList = new List <RequirePath>();
            if (document != null && document["paths"] != null)
            {
                paths.PathList = document["paths"]
                                 .Select(r => requirePathFrom((JProperty)r))
                                 .ToList();
            }

            return(paths);
        }
Exemple #6
0
        private RequirePaths GetPaths(XElement root)
        {
            var paths = new RequirePaths();

            paths.PathList = new List <RequirePath>();
            var pathEl = root.Element("paths");

            if (pathEl != null)
            {
                paths.PathList = pathEl.Descendants("path")
                                 .Select(r => requirePathFrom(r))
                                 .ToList();
            }

            return(paths);
        }
        private RequirePaths GetPaths(XElement root)
        {
            var paths = new RequirePaths();

            paths.PathList = new List <RequirePath>();
            var pathEl = root.Descendants("paths").FirstOrDefault();

            if (pathEl != null)
            {
                paths.PathList = pathEl.Descendants("path").Select(r => new RequirePath
                {
                    Key   = r.Attribute("key").Value,
                    Value = r.Attribute("value").Value
                }).ToList();
            }
            return(paths);
        }
        private RequirePaths GetPaths(JObject document)
        {
            var paths = new RequirePaths();

            paths.PathList = new List <RequirePath>();
            string parseSection = "paths";

            if (document != null && document[parseSection] != null)
            {
                JToken pathParent = JsonParseOrThrow <JObject>(document[parseSection], parseSection, Path, null);
                paths.PathList = pathParent
                                 .Select(r => requirePathFrom((JProperty)r))
                                 .ToList();
            }

            return(paths);
        }
Exemple #9
0
        private RequirePaths GetPaths(XElement root)
        {
            var paths = new RequirePaths();

            paths.PathList = new List <RequirePath>();
            var pathEl = root.Element("paths");

            if (pathEl != null)
            {
                paths.PathList = pathEl.Descendants("path")
                                 .Select(r => new RequirePath
                {
                    Key           = r.ReadStringAttribute("key"),
                    Value         = r.ReadStringAttribute("value"),
                    DefaultBundle = r.ReadStringAttribute("bundle", AttributeReadType.Optional)
                }).ToList();
            }

            return(paths);
        }
Exemple #10
0
        private void ApplyPathsOverride(RequirePaths originalPaths, RequirePaths overridePaths)
        {
            foreach (var pathEl in overridePaths.PathList)
            {
                var existing = originalPaths.PathList.Where(r => r.Key.ToLower() == pathEl.Key.ToLower()).FirstOrDefault();
                if (existing != null)
                {
                    existing.Value = pathEl.Value;
                }
                else
                {
                    originalPaths.PathList.Add(pathEl);
                }

                var existingValue = originalPaths.PathList.Where(r => r.Value.ToLower() == pathEl.Key.ToLower()).FirstOrDefault();
                if (existingValue != null)
                {
                    existingValue.Value = pathEl.Value;
                }
            }
        }
        private void ApplyPathsOverride(RequirePaths originalPaths, RequirePaths overridePaths)
        {
            foreach (var pathEl in overridePaths.PathList)
            {
                var existing = originalPaths.PathList.Where(r => r.Key.ToLower() == pathEl.Key.ToLower()).FirstOrDefault();

                if (existing != null)
                {
                    existing.ReplaceValues(pathEl.Value);
                }
                else
                {
                    originalPaths.PathList.Add(pathEl);
                }

                foreach (var pathElValue in pathEl.Value)
                {
                    foreach (var path in originalPaths.PathList)
                    {
                        path.ReplaceValue(pathEl.Key, pathElValue);
                    }
                }
            }
        }