-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringExtensions.cs
More file actions
30 lines (27 loc) · 963 Bytes
/
Copy pathStringExtensions.cs
File metadata and controls
30 lines (27 loc) · 963 Bytes
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
using System;
using System.Linq;
namespace NETMetaCoder
{
/// <summary>
/// Extension methods for <see cref="string"/>, relevant to the requirements of this library.
/// </summary>
public static class StringExtensions
{
/// <summary>
/// Transforms an attribute name so as to append it to a wrapped method's name.
/// </summary>
/// <param name="attributeName"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public static string ToAttributeNameNeedle(this string attributeName)
{
if (string.IsNullOrWhiteSpace(attributeName))
{
throw new ArgumentException("The attribute name must not be null or whitespace.",
nameof(attributeName));
}
attributeName = attributeName.Split('.').Last();
return $"__WrappedBy{attributeName}";
}
}
}