-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathExtensions.cs
More file actions
41 lines (35 loc) · 1.17 KB
/
Copy pathExtensions.cs
File metadata and controls
41 lines (35 loc) · 1.17 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
41
// Extensions.cs, 07.11.2019
// Copyright (C) Dominic Beger 07.11.2019
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace SharpMath
{
internal static class Extensions
{
public static IEnumerable<int> AllIndicesOf(this string str, string searchString)
{
var minIndex = str.IndexOf(searchString, StringComparison.Ordinal);
while (minIndex != -1)
{
yield return minIndex;
minIndex = str.IndexOf(searchString, minIndex + searchString.Length, StringComparison.Ordinal);
}
}
public static string GetEnumDescription(this Enum value)
{
var fi = value.GetType().GetField(value.ToString());
var attributes =
(DescriptionAttribute[]) fi.GetCustomAttributes(
typeof(DescriptionAttribute),
false);
if (attributes.Length > 0)
return attributes[0].Description;
return value.ToString();
}
public static bool IsBracket(this string s)
{
return s == "(" || s == ")";
}
}
}