summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/source/MonoGame.Extended.Content.Pipeline/Json/JsonContentProcessor.cs
blob: 6be4ac3604ad3ca18a9a0720675cdbd22cb40c85 (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
26
27
28
29
30
31
using System;
using System.ComponentModel;
using Microsoft.Xna.Framework.Content.Pipeline;

namespace MonoGame.Extended.Content.Pipeline.Json
{
    [ContentProcessor(DisplayName = "JSON Processor - MonoGame.Extended")]
    public class JsonContentProcessor : ContentProcessor<ContentImporterResult<string>, JsonContentProcessorResult>
    {
        [DefaultValue(typeof(Type), "System.Object")]
        public string ContentType { get; set; }

        public override JsonContentProcessorResult Process(ContentImporterResult<string> input, ContentProcessorContext context)
        {
            try
            {
                var output = new JsonContentProcessorResult
                {
                    ContentType = ContentType,
                    Json = input.Data
                };
                return output;
            }
            catch (Exception ex)
            {
                context.Logger.LogMessage("Error {0}", ex);
                throw;
            }
        }
    }
}