forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessorParameter.cs
More file actions
64 lines (54 loc) · 2.31 KB
/
Copy pathProcessorParameter.cs
File metadata and controls
64 lines (54 loc) · 2.31 KB
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
// MonoGame - Copyright (C) MonoGame Foundation, Inc
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
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>
[Serializable]
public sealed class ProcessorParameter
{
private PropertyInfo _propInfo;
/// <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)
PossibleEnumValues = new ReadOnlyCollection<string>(_propInfo.PropertyType.GetEnumNames());
}
/// <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 => PossibleEnumValues != null;
/// <summary>
/// Available options for enumerated type parameters. For parameters of other types, this value is null.
/// </summary>
public ReadOnlyCollection<string>? PossibleEnumValues { get; }
/// <summary>
/// Name of the property, as defined in the C# code.
/// </summary>
public string PropertyName => _propInfo.Name;
/// <summary>
/// Type of the parameter.
/// </summary>
public string PropertyType => _propInfo.PropertyType.Name;
}
}