-
Notifications
You must be signed in to change notification settings - Fork 509
Expand file tree
/
Copy pathNameSplitter.cs
More file actions
40 lines (36 loc) · 1.07 KB
/
NameSplitter.cs
File metadata and controls
40 lines (36 loc) · 1.07 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
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
namespace StyleCop.Analyzers.DocumentationRules
{
using System.Collections.Generic;
using System.Text;
/// <summary>
/// The name splitter.
/// </summary>
internal class NameSplitter
{
/// <summary>
/// Splits name by upper character.
/// </summary>
/// <param name="name">The name.</param>
/// <returns>A list of words.</returns>
public static IEnumerable<string> Split(string name)
{
var sb = new StringBuilder();
foreach (char c in name)
{
if (char.IsUpper(c) && sb.Length > 0)
{
yield return sb.ToString();
sb.Clear();
sb.Append(c);
}
else
{
sb.Append(c);
}
}
yield return sb.ToString();
}
}
}