forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleItemUtilities.cs
More file actions
40 lines (32 loc) · 1.13 KB
/
Copy pathSimpleItemUtilities.cs
File metadata and controls
40 lines (32 loc) · 1.13 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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Build.Framework;
using System;
using System.IO;
namespace Microsoft.NET.Build.Tasks
{
internal static partial class ItemUtilities
{
public static bool? GetBooleanMetadata(this ITaskItem item, string metadataName)
{
bool? result = null;
string value = item.GetMetadata(metadataName);
bool parsedResult;
if (bool.TryParse(value, out parsedResult))
{
result = parsedResult;
}
return result;
}
public static bool HasMetadataValue(this ITaskItem item, string name)
{
string value = item.GetMetadata(name);
return !string.IsNullOrEmpty(value);
}
public static bool HasMetadataValue(this ITaskItem item, string name, string expectedValue)
{
string value = item.GetMetadata(name);
return string.Equals(value, expectedValue, StringComparison.OrdinalIgnoreCase);
}
}
}