-
Notifications
You must be signed in to change notification settings - Fork 365
/
ContentFile.cs
111 lines (94 loc) · 4.43 KB
/
ContentFile.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//===============================================================================================================
// System : Sandcastle Help File Builder Utilities
// File : ContentFile.cs
// Author : Eric Woodruff (Eric@EWoodruff.us)
// Updated : 04/14/2021
// Note : Copyright 2015-2021, Eric Woodruff, All rights reserved
//
// This file contains a class representing a content file such as a token file, code snippet file, image, etc.
//
// This code is published under the Microsoft Public License (Ms-PL). A copy of the license should be
// distributed with the code and can be found at the project website: https://GitHub.com/EWSoftware/SHFB. This
// notice, the author's name, and all copyright notices must remain intact in all applications, documentation,
// and source files.
//
// Date Who Comments
// ==============================================================================================================
// 05/13/2015 EFW Created the code
//===============================================================================================================
using System;
using System.IO;
namespace SandcastleBuilder.Utils.ConceptualContent
{
/// <summary>
/// This represents a content file such as a token file, code snippet file, image, etc.
/// </summary>
public class ContentFile
{
#region Private data members
//=====================================================================
private readonly FilePath filePath;
private string linkPath;
#endregion
#region Properties
//=====================================================================
/// <summary>
/// This read-only property is used to get the base path provider
/// </summary>
public IBasePathProvider BasePathProvider => filePath.BasePathProvider;
/// <summary>
/// This read-only property is used to get the content filename without the path
/// </summary>
public string Filename => Path.GetFileName(filePath);
/// <summary>
/// This is used to get or set the full path to the content file
/// </summary>
/// <remarks>This returns the path to the file's true location. For linked items, this path will differ
/// from the <see cref="LinkPath"/> which returns the project-relative location.</remarks>
public string FullPath => filePath;
/// <summary>
/// This read-only property is used to get the persistable path to the content item (the path relative
/// to the project folder)
/// </summary>
public string PersistablePath => filePath.PersistablePath;
/// <summary>
/// This is used to get or set the link path to the content file (the project-relative location)
/// </summary>
/// <remarks>For linked items, this will be the location of the file within the project. For files
/// outside the project folder, this will not match the <see cref="FullPath"/> property value.</remarks>
public string LinkPath
{
get
{
if(String.IsNullOrWhiteSpace(linkPath))
return filePath;
return linkPath;
}
set => linkPath = value;
}
/// <summary>
/// This is used to get or set the sort order for site map and content layout files
/// </summary>
/// <value>For other file types, this will always return zero</value>
public int SortOrder { get; set; }
/// <summary>
/// This is used to get or set a provider that can be used to obtain content files from a project or some
/// other source.
/// </summary>
public IContentFileProvider ContentFileProvider { get; set; }
#endregion
#region Constructor
//=====================================================================
/// <summary>
/// Constructor
/// </summary>
/// <param name="filePath">The full path to the content file</param>
public ContentFile(FilePath filePath)
{
if(filePath == null || filePath.Path.Length == 0)
throw new ArgumentException("A full path to the content file is required", nameof(filePath));
this.filePath = filePath;
}
#endregion
}
}