-
Notifications
You must be signed in to change notification settings - Fork 0
/
NAStringExtensions.cs
44 lines (42 loc) · 1.76 KB
/
NAStringExtensions.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
/// <summary>
/// Extensions for <see cref="NAString"/>.
/// </summary>
public static class NAStringExtensions
{
/// <summary>
/// Checks if the value is found in the <see cref="NAString"/> cache, if not, it will be added and then returned.
/// </summary>
/// <param name="value"></param>
/// <param name="format"></param>
/// <returns>The cached value if found, otherwise it will be added and returned.</returns>
public static string ToNAString(this float value, string format = "")
{
if (NAString.IsCached(value)) return NAString.Borrow(value);
NAString.Allocate(value, format);
return NAString.Borrow(value);
}
/// <summary>
/// Checks if the value is found in the <see cref="NAString"/> cache, if not, it will be added and then returned.
/// </summary>
/// <param name="value"></param>
/// <param name="format"></param>
/// <returns>The cached value if found, otherwise it will be added and returned.</returns>
public static string ToNAString(this int value, string format = "")
{
if (NAString.IsCached(value)) return NAString.Borrow(value);
NAString.Allocate(value, format);
return NAString.Borrow(value);
}
/// <summary>
/// Checks if the value is found in the <see cref="NAString"/> cache, if not, it will be added and then returned.
/// </summary>
/// <param name="value"></param>
/// <param name="format"></param>
/// <returns>The cached value if found, otherwise it will be added and returned.</returns>
public static string ToNAString(this double value, string format = "")
{
if (NAString.IsCached(value)) return NAString.Borrow(value);
NAString.Allocate(value, format);
return NAString.Borrow(value);
}
}