forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContentProcessor.cs
63 lines (56 loc) · 2.36 KB
/
ContentProcessor.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
using System;
namespace Microsoft.Xna.Framework.Content.Pipeline
{
/// <summary>
/// Provides a base class to use when developing custom processor components. All processors must derive from this class.
/// </summary>
public abstract class ContentProcessor<TInput, TOutput> : IContentProcessor
{
/// <summary>
/// Initializes a new instance of the ContentProcessor class.
/// </summary>
protected ContentProcessor()
{
}
/// <summary>
/// Processes the specified input data and returns the result.
/// </summary>
/// <param name="input">Existing content object being processed.</param>
/// <param name="context">Contains any required custom process parameters.</param>
/// <returns>A typed object representing the processed input.</returns>
public abstract TOutput Process(TInput input, ContentProcessorContext context);
/// <summary>
/// Gets the expected object type of the input parameter to IContentProcessor.Process.
/// </summary>
Type IContentProcessor.InputType
{
get { return typeof(TInput); }
}
/// <summary>
/// Gets the object type returned by IContentProcessor.Process.
/// </summary>
Type IContentProcessor.OutputType
{
get { return typeof(TOutput); }
}
/// <summary>
/// Processes the specified input data and returns the result.
/// </summary>
/// <param name="input">Existing content object being processed.</param>
/// <param name="context">Contains any required custom process parameters.</param>
/// <returns>The processed input.</returns>
object IContentProcessor.Process(object input, ContentProcessorContext context)
{
if (input == null)
throw new ArgumentNullException("input");
if (context == null)
throw new ArgumentNullException("context");
if (!(input is TInput))
throw new InvalidOperationException("input is not of the expected type");
return Process((TInput)input, context);
}
}
}