public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var root   = JObject.Load(reader);
            var config = new DependencyConfiguration();

            config.Key     = reader.Path;
            config.Version = GetPropValue(root, "version");
            config.Url     = GetPropValue(root, "url");

            var pages = root["pages"] as JObject;

            if (pages != null && pages.HasValues)
            {
                config.Pages = pages.Properties().Aggregate(
                    new Dictionary <string, string>(),
                    (seed, p) =>
                {
                    seed.Add(p.Name, UrlFormat(config, p));
                    return(seed);
                }
                    );
            }

            var api = root["api"] as JObject;

            if (api != null && api.HasValues)
            {
                config.Api = api.Properties().Aggregate(
                    new Dictionary <string, string>(),
                    (seed, p) =>
                {
                    seed.Add(p.Name, UrlFormat(config, p));
                    return(seed);
                }
                    );
            }

            return(config);
        }
 private static string UrlFormat(DependencyConfiguration config, JProperty p)
 {
     return(string.Format("{0}/{1}/{2}/{3}", (config.Url == "/") ? string.Empty : config.Url, config.Key, config.Version, p.Value));
 }