Example #1
0
        /// <summary>
        /// Deserialize the content of the file and rebuild the list of IConfigs.
        /// </summary>
        /// <param name="reader">The reader to pull in from.</param>
        /// <param name="serializer">The helper serializer.</param>
        /// <returns>The rebuilt file content.</returns>
        protected override List <IConfig> DeserializeContent(JsonReader reader, JsonSerializer serializer)
        {
            List <IConfig> configs = new List <IConfig>();

            //We aren't sure if the file has been modified. Hence the try / catch.
            try {
                while (reader.Read())
                {
                    if (reader.Value != null && reader.TokenType == JsonToken.PropertyName)
                    {
                        ConfigType configType = (ConfigType)Enum.Parse(typeof(ConfigType), reader.Value.ToString());
                        reader.Read();

                        Type    type   = configType.GetObjectType();
                        IConfig config = Activator.CreateInstance(type, reader, serializer) as IConfig;

                        if (config != null)
                        {
                            configs.Add(config);
                        }

                        reader.Skip();
                    }
                }
            }
            catch {
            }

            return(configs);
        }