Пример #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;
        }
Пример #2
0
        public void OverridePathsWithSameKey()
        {
            var jqueryPath = new RequirePath { Key = "jquery", Value = "jquery-1.06.2" };
            var altJqueryPath = new RequirePath { Key = "jquery", Value = "jquery-1.05.3" };

            var firstCollection = ConfigurationCreators.CreateCollectionWithPaths(jqueryPath);
            var secondCollection = ConfigurationCreators.CreateCollectionWithPaths(altJqueryPath);

            var merger = ConfigurationCreators.CreateDefaultConfigMerger(firstCollection, secondCollection);
            var merged = merger.GetMerged();

            var expected = ConfigurationCreators.CreateCollectionWithPaths(altJqueryPath);

            CustomAssert.JsonEquals(expected, merged);
        }
Пример #3
0
        public void UnitePathsWhenKeysAreDifferent()
        {
            var jqueryPath = new RequirePath { Key = "jquery", Value = "jquery-1.06.2" };
            var amplifyPath = new RequirePath { Key = "amplify", Value = "amplify-10.3.5" };

            var firstCollection = ConfigurationCreators.CreateCollectionWithPaths(jqueryPath);
            var secondCollection = ConfigurationCreators.CreateCollectionWithPaths(amplifyPath);

            var merger = ConfigurationCreators.CreateDefaultConfigMerger(firstCollection, secondCollection);
            var merged = merger.GetMerged();

            var expected = ConfigurationCreators.CreateCollectionWithPaths(jqueryPath, amplifyPath);

            CustomAssert.JsonEquals(expected, merged);
        }
Пример #4
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;
                        if (pathObj["path"] == null || pathObj["defaultBundle"] == null)
                            throw new ArgumentException("Expected an object with 'path' and 'defaultBundle' but got " + pathObj.ToString());
                        result.Value = pathObj["path"].ToString();
                        result.DefaultBundle = pathObj["defaultBundle"].ToString();
                    }

                    return result;
                }).ToList();
            }

            return paths;
        }