//public List<ConfigurationBase> Read()
        //{
        //    return null;
        //}

        public List <ConfigurationSet> Parse(string json)
        {
            using (JsonTextReader reader = new JsonTextReader(new StringReader(json)))
            {
                JObject jObject;
                try
                {
                    jObject = JObject.Load(reader);
                }
                catch (Exception exception)
                {
                    throw new InvalidConfigurationException("Can not load json. See inner exception for details", exception);
                }
                ConfigurationVersion version = jObject.ToObject <ConfigurationVersion>();
                if (version?.Generate == null)
                {
                    throw new InvalidConfigurationException("Unsupported configuration found. Generate tag is missing.");
                }
                if (version.Version == 0)
                {
                    version.Version = this.versions.Max(x => x.Key);
                    Logger.Warning($"No version found. Fallback to {version.Version}");
                }
                if (version.Load != null && version.Load.Count > 0)
                {
                    this.resolver.Create <GeneratorModuleLoader>().Load(version.Load);
                }
                if (this.versions.ContainsKey(version.Version))
                {
                    return(this.versions[version.Version].Read(version));
                }
                throw new InvalidConfigurationException($"No reader for version {version.Version} found");
            }
        }
        public List <ConfigurationSet> Read(ConfigurationVersion version)
        {
            List <ConfigurationSet> list = new List <ConfigurationSet>();

            if (version.Generate is JObject obj)
            {
                ConfigurationSet set = new ConfigurationSet();
                this.ReadToPair(obj, set);
                list.Add(set);
            }
            else if (version.Generate is JArray array)
            {
                if (array.First is JObject)
                {
                    ConfigurationSet set = new ConfigurationSet();
                    foreach (JObject entry in array.OfType <JObject>())
                    {
                        this.ReadToPair(entry, set);
                    }
                    list.Add(set);
                }
                else if (array.First is JArray)
                {
                    foreach (JArray innerArray in array.OfType <JArray>())
                    {
                        ConfigurationSet set = new ConfigurationSet();
                        foreach (JObject entry in innerArray.OfType <JObject>())
                        {
                            this.ReadToPair(entry, set);
                        }
                        list.Add(set);
                    }
                }
            }
            list.ForEach(pair => pair.Readers.ForEach(reader => reader.Formatting = reader.Formatting ?? version.Formatting));
            list.ForEach(pair => pair.Writers.ForEach(writer => writer.Formatting = writer.Formatting ?? version.Formatting));
            return(list);
        }