summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Serialization/ProfileJsonConverter.cs
blob: 8d98079178b69621cec9d8092b33e707aba8174d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using MonoGame.Extended.Particles.Profiles;
using MonoGame.Extended.Serialization;

namespace MonoGame.Extended.Particles.Serialization
{
    public class ProfileJsonConverter : BaseTypeJsonConverter<Profile>
    {
        public ProfileJsonConverter()
            : base(GetSupportedTypes(), nameof(Profile))
        {
        }

        private static IEnumerable<TypeInfo> GetSupportedTypes()
        {
            return typeof(Profile)
                .GetTypeInfo()
                .Assembly
                .DefinedTypes
                .Where(type => type.IsSubclassOf(typeof(Profile)) && !type.IsAbstract);
        }
    }
}