﻿namespace SnappyMap.IO
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    using SnappyMap.Data;

    [Serializable]
    public struct SectionMapping
    {
        public SectionMapping(SectionType type, params string[] sections)
            : this()
        {
            this.Type = type;
            this.Sections = sections.ToList();
        }

        public SectionType Type { get; set; }

        public List<string> Sections { get; set; }
    }

    [Serializable]
    public class SectionConfig
    {
        public SectionConfig()
        {
            this.SectionMappings = new List<SectionMapping>();
        }

        public int SeaLevel { get; set; }

        public List<SectionMapping> SectionMappings { get; private set; }
    }
}

﻿namespace SnappyMap.IO
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    using SnappyMap.Data;

    [Serializable]
    public struct SectionMapping
    {
        public SectionMapping(SectionType type, params string[] sections)
            : this()
        {
            this.Type = type;
            this.Sections = sections.ToList();
        }

        public SectionType Type { get; set; }

        public List<string> Sections { get; set; }
    }

    [Serializable]
    public class SectionConfig
    {
        public SectionConfig()
        {
            this.SectionMappings = new List<SectionMapping>();
        }

        public int SeaLevel { get; set; }

        public List<SectionMapping> SectionMappings { get; set; }
    }
}

Fix potential crash in old .NET versions
Fix potential crash in old .NET versions

Apparently in older .NET the XML deserializer
doesn't like it when the type to be deserialized
has properties with private setters.

https://stackoverflow.com/questions/891449/xmlserializer-and-collection-property-with-private-setter
https://www.fmork.net/software/writing/2010/Readonly-collection-properties-and-XmlSerializer.htm
https://stackoverflow.com/questions/23809092/unable-to-generate-a-temporary-class-result-1-cs0200
