forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentInfo.cs
More file actions
49 lines (41 loc) · 2.47 KB
/
Copy pathContentInfo.cs
File metadata and controls
49 lines (41 loc) · 2.47 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
// 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 Microsoft.Xna.Framework.Content.Pipeline;
namespace MonoGame.Framework.Content.Pipeline.Builder;
/// <summary>
/// Describes how the <see cref="ContentBuilder"/> should handle the content.
/// </summary>
/// <param name="shouldBuild">Indicates if the content should be built or copied.</param>
/// <param name="contentRoot">The desired content root that will get prefixed to the output path.</param>
/// <param name="importer">The desired <see cref="IContentImporter"/> to be used for the content building.</param>
/// <param name="processor">The desired <see cref="IContentProcessor"/> to be used for the content building.</param>
/// <param name="outputPath">The desired output path to be setup based on the input path to the content.</param>
public class ContentInfo(string contentRoot = "", bool shouldBuild = true, IContentImporter? importer = null, IContentProcessor? processor = null, Func<string, string>? outputPath = null)
{
private readonly Func<string, string> _outputPath = outputPath ?? (s => s);
/// <summary>
/// A relative path to be used as a prefix to the output path.
/// </summary>
public string ContentRoot { get; init; } = contentRoot;
/// <summary>
/// <c>true</c> if the content should be built, <c>false</c> if the content should be copied.
/// </summary>
public bool ShouldBuild { get; init; } = shouldBuild;
/// <summary>
/// An <see cref="IContentImporter"/> to be used for the building, if its not specified,
/// the system will use reflection to try to figure out an apropriate importer.
/// </summary>
public IContentImporter? Importer { get; init; } = importer;
/// <summary>
/// An <see cref="IContentProcessor"/> to be used for the building, if its not specified,
/// the system will use reflection to try to figure out an apropriate processor.
/// </summary>
public IContentProcessor? Processor { get; init; } = processor;
/// <summary>
/// Gets the desired output path for the current <see cref="ShouldBuild"/> operation.
/// </summary>
/// <param name="filePath">A relative path to the content file (without extension in case of build action).</param>
/// <returns>Desired relative path for the output content.</returns>
public string GetOutputPath(string filePath) => _outputPath(filePath);
}