-
Notifications
You must be signed in to change notification settings - Fork 4
/
Filter.cs
38 lines (34 loc) · 1.32 KB
/
Filter.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
using System.Xml.Linq;
namespace DSPtoVCXPROJ;
/// <summary>
/// The <see cref="Filter" /> block contains the information for a filter to be applied to an object, so it can be placed within a specific
/// filter in the IDE. This encompasses both the general filters, which contain the extensions, as well as being used on the objects
/// themselves to say which filter they are contained within.
/// </summary>
class Filter
{
public string Include { get; }
public string? Extensions { get; set; }
public Filter(string include) => this.Include = include;
/// <summary>
/// Gets the block as an <see cref="XElement" />.
/// </summary>
/// <param name="IncludeAsAttrib">
/// If <see langword="true" />, the block is generated for the primary ItemGroup of the filters file,
/// if <see langword="false" />, the block is generated for an individual item.
/// </param>
/// <param name="elements">Additional child <see cref="XElement" />s for the block.</param>
/// <returns>The block as an <see cref="XElement" />.</returns>
public XElement GetBlock(bool IncludeAsAttrib, params object[] elements)
{
var block = Program.CreateElement(nameof(Filter), elements);
if (IncludeAsAttrib)
{
block.AddAttributeIfNotBlank(this.Include);
block.AddIfNotBlank(this.Extensions);
}
else
block.Add(this.Include);
return block;
}
}