forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProcessorParameter.cs
90 lines (80 loc) · 2.66 KB
/
ProcessorParameter.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// 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;
using System.Collections.ObjectModel;
using System.Reflection;
namespace Microsoft.Xna.Framework.Content.Pipeline
{
/// <summary>
/// Represents a processor parameter. Processor parameters are automatically discovered by the content pipeline. Therefore, only custom processor developers should use this class directly.
/// </summary>
[SerializableAttribute]
public sealed class ProcessorParameter
{
PropertyInfo propInfo;
ReadOnlyCollection<string> enumValues;
/// <summary>
/// Default value of the processor parameter.
/// </summary>
public Object DefaultValue { get; set; }
/// <summary>
/// Description of the parameter, as specified by the [Description] attribute.
/// </summary>
public string Description { get; set; }
/// <summary>
/// Name of the parameter displayed in the designer, as specified by the [DisplayName] attribute.
/// </summary>
public string DisplayName { get; set; }
/// <summary>
/// Gets a value indicating whether the parameter is an enumeration.
/// </summary>
public bool IsEnum
{
get
{
return enumValues != null;
}
}
/// <summary>
/// Available options for enumerated type parameters. For parameters of other types, this value is null.
/// </summary>
public ReadOnlyCollection<string> PossibleEnumValues
{
get
{
return enumValues;
}
}
/// <summary>
/// Name of the property, as defined in the C# code.
/// </summary>
public string PropertyName
{
get
{
return propInfo.Name;
}
}
/// <summary>
/// Type of the parameter.
/// </summary>
public string PropertyType
{
get
{
return propInfo.PropertyType.Name;
}
}
/// <summary>
/// Constructs a ProcessorParameter instance.
/// </summary>
/// <param name="propertyInfo">The info for the property.</param>
internal ProcessorParameter(PropertyInfo propertyInfo)
{
propInfo = propertyInfo;
if (propInfo.PropertyType.IsEnum)
enumValues = new ReadOnlyCollection<string>(propInfo.PropertyType.GetEnumNames());
}
}
}