Exemplo n.º 1
0
        AutoBundleItem autoBundleItemFrom(JToken token, string parseSectionHint)
        {
            var target = new AutoBundleItem();

            var source = token as JObject;

            if (source == null)
            {
                return(target);
            }

            target.BundleId  = JsonParseStringOrThrow(source, "bundleId", parseSectionHint, Path);
            target.File      = JsonParseStringOrThrow(source, "file", parseSectionHint, Path);
            target.Directory = JsonParseStringOrThrow(source, "directory", parseSectionHint, Path);

            var numberOfDefinedProperties = new[] { target.BundleId, target.File, target.Directory }.Where(x => x != null).Count();

            if (numberOfDefinedProperties != 1)
            {
                throw new ArgumentException("Expected object with exactly one of 'bundleId', 'file' or 'directory' but got " + source.ToString());
            }

            return(target);
        }
Exemplo n.º 2
0
        AutoBundleItem autoBundleItemFrom(JToken token)
        {
            var target = new AutoBundleItem();

            var source = token as JObject;

            if (source == null)
            {
                return(target);
            }

            target.BundleId  = source["bundleId"] != null ? source["bundleId"].ToString() : null;
            target.File      = source["file"] != null ? source["file"].ToString() : null;
            target.Directory = source["directory"] != null ? source["directory"].ToString() : null;

            var numberOfDefinedProperties = new[] { target.BundleId, target.File, target.Directory }.Where(x => x != null).Count();

            if (numberOfDefinedProperties != 1)
            {
                throw new ArgumentException("Expected object with exactly one of 'bundleId', 'file' or 'directory' but got " + source.ToString());
            }

            return(target);
        }
Exemplo n.º 3
0
        private AutoBundles GetAutoBundles(JObject document)
        {
            var autoBundles = new AutoBundles();

            autoBundles.Bundles = new List <AutoBundle>();
            if (document != null && document["autoBundles"] != null)
            {
                autoBundles.Bundles = document["autoBundles"].Select(
                    r =>
                {
                    var currentBundle = new AutoBundle();
                    var prop          = (JProperty)r;
                    currentBundle.Id  = prop.Name;
                    var valueObj      = prop.Value as JObject;
                    if (valueObj != null)
                    {
                        currentBundle.OutputPath       = valueObj["outputPath"] != null ? valueObj["outputPath"].ToString() : null;
                        currentBundle.ContainingConfig = Path;
                        currentBundle.Includes         = new List <AutoBundleItem>();
                        if (valueObj["include"] != null)
                        {
                            currentBundle.Includes = valueObj["include"].Select(
                                x =>
                            {
                                var includesObj = x as JObject;
                                var inclItem    = new AutoBundleItem();
                                if (includesObj == null)
                                {
                                    return(inclItem);
                                }

                                inclItem.BundleId  = includesObj["bundleId"] != null ? includesObj["bundleId"].ToString() : null;
                                inclItem.File      = includesObj["file"] != null ? includesObj["file"].ToString() : null;
                                inclItem.Directory = includesObj["directory"] != null ? includesObj["directory"].ToString() : null;
                                return(inclItem);
                            })
                                                     .ToList();
                        }
                        currentBundle.Excludes = new List <AutoBundleItem>();
                        if (valueObj["exclude"] != null)
                        {
                            currentBundle.Excludes = valueObj["exclude"].Select(
                                x =>
                            {
                                var includesObj = x as JObject;
                                var inclItem    = new AutoBundleItem();
                                if (includesObj == null)
                                {
                                    return(inclItem);
                                }

                                inclItem.BundleId  = includesObj["bundleId"] != null ? includesObj["bundleId"].ToString() : null;
                                inclItem.File      = includesObj["file"] != null ? includesObj["file"].ToString() : null;
                                inclItem.Directory = includesObj["directory"] != null ? includesObj["directory"].ToString() : null;
                                return(inclItem);
                            })
                                                     .ToList();
                        }
                    }

                    return(currentBundle);
                }).ToList();
            }

            return(autoBundles);
        }