コード例 #1
0
        private static IDictionary<string, IDictionary<string, string>> TransformMaps(Property maps)
        {
            var result = new Dictionary<string, IDictionary<string, string>>();

            if (maps?.Value?.Type != SyntaxNodes.ObjectExpression)
            {
                return result;
            }

            var objexpr = maps.Value as ObjectExpression;

            foreach (var p in objexpr.Properties)
            {
                var key = p.Key.GetKey();

                var literal = p.Value.As<ObjectExpression>();
                if (literal == null)
                {
                    continue;
                }

                var dict = new Dictionary<string, string>();

                foreach (var m in literal.Properties)
                {
                    dict[m.Key.GetKey()] = m.Value.GetValue(literal);
                }

                result[p.Key.GetKey()] = dict;
            }

            return result;
        }
コード例 #2
0
        private static IEnumerable<RequirePackage> TransformPackages(SyntaxNode root, Property packages)
        {
            if (packages?.Value?.Type != SyntaxNodes.ArrayExpression)
            {
                return Enumerable.Empty<RequirePackage>();
            }

            var array = packages.Value.As<ArrayExpression>();

            return (from package in array.Elements
                    where package.Type == SyntaxNodes.ObjectExpression
                    select package.As<ObjectExpression>())
                .Select(
                    expr => new RequirePackage
                            {
                                Location = expr.GetProperty("location")?.GetValue(root),
                                Name = expr.GetProperty("name")?.GetValue(root),
                                Main = expr.GetProperty("main")?.GetValue(root)
                            })
                .Where(package =>
                       !string.IsNullOrEmpty(package.Location) ||
                       !string.IsNullOrEmpty(package.Name) ||
                       !string.IsNullOrEmpty(package.Main));
        }
コード例 #3
0
        private static IDictionary<string, string> TransformPaths(SyntaxNode root, Property paths)
        {
            var result = new Dictionary<string, string>();

            if (paths.Value?.Type != SyntaxNodes.ObjectExpression)
            {
                return result;
            }

            var expr = paths.Value.As<ObjectExpression>();

            foreach (var p in expr.Properties)
            {
                result[p.Key.GetKey()] = p.GetValue(root);
            }

            return result;
        }