mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 03:01:31 +00:00
Rename to Octokit to be consistent with other API libs
GitHub is naming all of the libraries Octokit for their respective platforms
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
internal static class StringExtensions
|
||||
{
|
||||
public static bool IsBlank(this string value)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(value);
|
||||
}
|
||||
|
||||
public static bool IsNotBlank(this string value)
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(value);
|
||||
}
|
||||
|
||||
public static Uri FormatUri(this string pattern, params object[] args)
|
||||
{
|
||||
return new Uri(string.Format(CultureInfo.InvariantCulture, pattern, args), UriKind.Relative);
|
||||
}
|
||||
|
||||
// :trollface:
|
||||
[SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase",
|
||||
Justification = "Ruby don't care. Ruby don't play that.")]
|
||||
public static string ToRubyCase(this string propertyName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(propertyName, "s");
|
||||
return string.Join("_", propertyName.SplitUpperCase()).ToLowerInvariant();
|
||||
}
|
||||
|
||||
static IEnumerable<string> SplitUpperCase(this string source)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(source, "source");
|
||||
|
||||
int wordStartIndex = 0;
|
||||
var letters = source.ToCharArray();
|
||||
var previousChar = char.MinValue;
|
||||
|
||||
// Skip the first letter. we don't care what case it is.
|
||||
for (int i = 1; i < letters.Length; i++)
|
||||
{
|
||||
if (char.IsUpper(letters[i]) && !char.IsWhiteSpace(previousChar))
|
||||
{
|
||||
//Grab everything before the current character.
|
||||
yield return new String(letters, wordStartIndex, i - wordStartIndex);
|
||||
wordStartIndex = i;
|
||||
}
|
||||
previousChar = letters[i];
|
||||
}
|
||||
|
||||
//We need to have the last word.
|
||||
yield return new String(letters, wordStartIndex, letters.Length - wordStartIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user