char.ToUpperInvariant(char)

Here are the examples of the csharp api char.ToUpperInvariant(char) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

263 Examples 7

19 Source : DriveLetterToIdConverter.cs
with MIT License
from 13xforever

public static int ToDriveId(this char driveLetter)
        {
            driveLetter = char.ToUpperInvariant(driveLetter);
            if (driveLetter < 'A' || driveLetter > 'Z')
                return 0;

            return 1 << (driveLetter - 'A');
        }

19 Source : CompletionList.cs
with MIT License
from Abdesol

static bool CamelCaseMatch(string text, string query)
		{
			// We take the first letter of the text regardless of whether or not it's upper case so we match
			// against camelCase text as well as PascalCase text ("cct" matches "camelCaseText")
			var theFirstLetterOfEachWord = text.Take(1).Concat(text.Skip(1).Where(char.IsUpper));

			int i = 0;
			foreach (var letter in theFirstLetterOfEachWord) {
				if (i > query.Length - 1)
					return true;    // return true here for CamelCase partial match ("CQ" matches "CodeQualityreplacedysis")
				if (char.ToUpperInvariant(query[i]) != char.ToUpperInvariant(letter))
					return false;
				i++;
			}
			if (i >= query.Length)
				return true;
			return false;
		}

19 Source : XmlSerializableDataContractExtensions.cs
with MIT License
from actions

private static string ConvertToUpperCamelCase(string input)
            {
                return string.Concat(char.ToUpperInvariant(input[0]), input.Substring(1));
            }

19 Source : StringExtensions.cs
with GNU General Public License v3.0
from Acumatica

public static string ToPascalCase(this string s)
		{
			if (s.IsNullOrWhiteSpace() || char.IsUpper(s[0]))
				return s;

			return s.Length > 1 
				? char.ToUpperInvariant(s[0]).ToString() + s.Substring(1)
				: char.ToUpperInvariant(s[0]).ToString();
		}

19 Source : TypoInViewDelegateNameFix.cs
with GNU General Public License v3.0
from Acumatica

private static string GenerateViewDelegateName(string viewName)
		{
			var chars = viewName.ToCharArray();
			char firstChar = chars[0];
			if (Char.IsUpper(firstChar))
			{
				firstChar = Char.ToLowerInvariant(firstChar);
			}
			else if (Char.IsLower(firstChar))
			{
				firstChar = Char.ToUpperInvariant(firstChar);
			}

			chars[0] = firstChar;

			return new string(chars);
		}

19 Source : LocalFileLocator.cs
with MIT License
from ADeltaX

public override bool HasCommonRoot(FileLocator other)
        {
            LocalFileLocator otherLocal = other as LocalFileLocator;
            if (otherLocal == null)
            {
                return false;
            }

            // If the paths have drive specifiers, then common root depends on them having a common
            // drive letter.
            string otherDir = otherLocal._dir;
            if (otherDir.Length >= 2 && _dir.Length >= 2)
            {
                if (otherDir[1] == ':' && _dir[1] == ':')
                {
                    return char.ToUpperInvariant(otherDir[0]) == char.ToUpperInvariant(_dir[0]);
                }
            }

            return true;
        }

19 Source : SubKeyHashedListCell.cs
with MIT License
from ADeltaX

private uint CalcHash(string name)
        {
            uint hash = 0;
            if (_hashType == "lh")
            {
                for (int i = 0; i < name.Length; ++i)
                {
                    hash *= 37;
                    hash += char.ToUpperInvariant(name[i]);
                }
            }
            else
            {
                string hashStr = name + "\0\0\0\0";
                for (int i = 0; i < 4; ++i)
                {
                    hash |= (uint)((hashStr[i] & 0xFF) << (i * 8));
                }
            }

            return hash;
        }

19 Source : SubKeyHashedListCell.cs
with MIT License
from ADeltaX

private IEnumerable<int> FindByPrefix(string name, int start)
        {
            int compChars = Math.Min(name.Length, 4);
            string compStr = name.Substring(0, compChars).ToUpperInvariant() + "\0\0\0\0";

            for (int i = start; i < _nameHashes.Count; ++i)
            {
                bool match = true;
                uint hash = _nameHashes[i];

                for (int j = 0; j < 4; ++j)
                {
                    char ch = (char)((hash >> (j * 8)) & 0xFF);
                    if (char.ToUpperInvariant(ch) != compStr[j])
                    {
                        match = false;
                        break;
                    }
                }

                if (match)
                {
                    yield return i;
                }
            }
        }

19 Source : UpperCamelCaseNamingStrategy.cs
with MIT License
from AElfProject

protected override string ResolvePropertyName(string name)
        {
            var result = base.ResolvePropertyName(name);
            result = char.ToUpperInvariant(result[0]) + result.Substring(1);
            return result;
        }

19 Source : DHLServicesValidator.cs
with MIT License
from alexeybusygin

public static bool IsServiceValid(char c) =>
            DHLProvider.AvailableServices.ContainsKey(char.ToUpperInvariant(c));

19 Source : DHLServicesValidator.cs
with MIT License
from alexeybusygin

public static char[] GetValidServices(char[] services)
        {
            return (services ?? Array.Empty<char>())
                .Select(c => char.ToUpperInvariant(c))
                .Where(c => DHLProvider.AvailableServices.ContainsKey(c)).ToArray();
        }

19 Source : Core.cs
with MIT License
from AliFlux

public static string ToUpperCamelCase(string s)
        {
            return Char.ToUpperInvariant(s[0]) + s.Substring(1);
        }

19 Source : CharExtension.cs
with MIT License
from AlphaYu

public static char ToUpperInvariant(this char c)
        {
            return char.ToUpperInvariant(c);
        }

19 Source : YoloConfigParser.cs
with MIT License
from AlturosDestinations

private static string SnakeCaseToPascalCase(string snakeCase)
        {
            return snakeCase.Split(new[] { "_" }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => char.ToUpperInvariant(s[0]) + s.Substring(1, s.Length - 1)).Aggregate(string.Empty, (s1, s2) => s1 + s2);
        }

19 Source : CsCodeGenerator.Enum.cs
with MIT License
from amerkoleci

private static string GetEnumItemName(CppEnum @enum, string cppEnumItemName, string enumNamePrefix)
        {
            string enumItemName;
            if (@enum.Name == "VkFormat")
            {
                enumItemName = cppEnumItemName.Substring(enumNamePrefix.Length + 1);
                var splits = enumItemName.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                if (splits.Length <= 1)
                {
                    enumItemName = char.ToUpperInvariant(enumItemName[0]) + enumItemName.Substring(1).ToLowerInvariant();
                }
                else
                {
                    var sb = new StringBuilder();
                    foreach (var part in splits)
                    {
                        if (part.Equals("UNORM", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("UNorm");
                        }
                        else if (part.Equals("SNORM", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("SNorm");
                        }
                        else if (part.Equals("UINT", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("UInt");
                        }
                        else if (part.Equals("SINT", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("SInt");
                        }
                        else if (part.Equals("PACK8", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("Pack8");
                        }
                        else if (part.Equals("PACK16", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("Pack16");
                        }
                        else if (part.Equals("PACK32", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("Pack32");
                        }
                        else if (part.Equals("USCALED", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("UScaled");
                        }
                        else if (part.Equals("SSCALED", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("SScaled");
                        }
                        else if (part.Equals("UFLOAT", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("UFloat");
                        }
                        else if (part.Equals("SFLOAT", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("SFloat");
                        }
                        else if (part.Equals("SRGB", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("SRgb");
                        }
                        else if (part.Equals("BLOCK", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("Block");
                        }
                        else if (part.Equals("IMG", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("Img");
                        }
                        else if (part.Equals("2PACK16", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("2Pack16");
                        }
                        else if (part.Equals("3PACK16", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("3Pack16");
                        }
                        else if (part.Equals("4PACK16", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("4Pack16");
                        }
                        else if (part.Equals("2PLANE", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("2Plane");
                        }
                        else if (part.Equals("3PLANE", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("3Plane");
                        }
                        else if (part.Equals("4PLANE", StringComparison.OrdinalIgnoreCase))
                        {
                            sb.Append("4Plane");
                        }
                        else
                        {
                            sb.Append(part);
                        }
                    }

                    enumItemName = sb.ToString();
                }
            }
            else
            {
                enumItemName = GetPrettyEnumName(cppEnumItemName, enumNamePrefix);
            }

            return enumItemName;
        }

19 Source : CombatantEx.cs
with BSD 3-Clause "New" or "Revised" License
from anoyetta

private static string ToCamelCase(
            string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return string.Empty;
            }

            if (name.Length == 1)
            {
                return name.ToUpper();
            }

            return Char.ToUpperInvariant(name[0]) + name.Substring(1).ToLowerInvariant();
        }

19 Source : Functions.cs
with MIT License
from ansel86castro

[ParserFunction]
        public static string Capitalize(this string s)
        {
            if (string.IsNullOrWhiteSpace(s))
                return s;

            if (s.Length == 1)
                return s.ToUpper();

            var firstLetter = s[0];            

            return char.ToUpperInvariant(firstLetter) + s.Substring(1);
        }

19 Source : Functions.cs
with MIT License
from ansel86castro

[ParserFunction]
        public static string Pascal(this string s)
        {
            var sections = s.Split('_');
            StringBuilder sb = new StringBuilder();
            foreach (var part in sections)
            {

                for (int i = 0; i < part.Length; i++)
                {
                    var c = part[i];
                    if (i == 0)
                    {
                        sb.Append(char.ToUpperInvariant(c));
                    }
                    else if (i < part.Length - 1 && char.IsLower(part[i - 1]) && char.IsUpper(c))
                    {
                        sb.Append(c);
                    }
                    else
                    {
                        sb.Append(char.ToLowerInvariant(c));
                    }

                }             
            }

            var result = sb.ToString();
            if(result.All(x => char.IsDigit(x)))
            {
                result = "_" + result;
            }

            return result;
        }

19 Source : CybtansModelBinder.cs
with MIT License
from ansel86castro

public static string Pascal(string s)
        {
            var sections = s.Split('_');
            StringBuilder sb = new StringBuilder();
            foreach (var part in sections)
            {

                for (int i = 0; i < part.Length; i++)
                {
                    var c = part[i];
                    if (i == 0)
                    {
                        sb.Append(char.ToUpperInvariant(c));
                    }
                    else if (i < part.Length - 1 && char.IsLower(part[i - 1]) && char.IsUpper(c))
                    {
                        sb.Append(c);
                    }
                    else
                    {
                        sb.Append(char.ToLowerInvariant(c));
                    }

                }
            }

            var result = sb.ToString();
            if (result.All(x => char.IsDigit(x)))
            {
                result = "_" + result;
            }

            return result;
        }

19 Source : StringExtentionsMethods.cs
with Apache License 2.0
from AppRopio

public static string ToFirstCharUppercase(this string self)
        {
            return $"{char.ToUpperInvariant(self[0])}{self.Substring(1)}";
        }

19 Source : Util.cs
with MIT License
from araditc

internal static string Capitalize(this string s) {
			return char.ToUpperInvariant(s[0]) + s.Substring(1);
		}

19 Source : Program.cs
with MIT License
from ardalis

static void Main(string[] args)
        {

#if SupportUndo
            // MEMENTO NOTES:
            // HangmanGameWithUndo == ORIGINATOR
            // This Main Program   == CARETAKER
            // HangmanMemento      == MEMENTO
            var game = new HangmanGameWithUndo();
            var gameHistory = new Stack<HangmanMemento>();
            gameHistory.Push(game.CreateSetPoint());
#else
            var game = new HangmanGame();
#endif

            while (!game.IsOver)
            {
                Console.Clear();
                Console.SetCursorPosition(0, 0);
                Console.WriteLine("Welcome to Hangman");

                Console.WriteLine(game.CurrentMaskedWord);
                Console.WriteLine($"Previous Guesses: {String.Join(',', game.PreviousGuesses.ToArray())}");
                Console.WriteLine($"Guesses Left: {game.GuessesRemaining}");

#if SupportUndo
                Console.WriteLine("Guess (a-z or '-' to undo last guess): ");
#else
                Console.WriteLine("Guess (a-z): ");
#endif

                var entry = char.ToUpperInvariant(Console.ReadKey().KeyChar);

#if SupportUndo
                if(entry == '-')
                {
                    if(gameHistory.Count > 1)
                    {
                        gameHistory.Pop();
                        game.ResumeFrom(gameHistory.Peek());
                        Console.WriteLine();
                        continue;
                    }
                }
#endif
                try
                {
                    game.Guess(entry);
#if SupportUndo
                    gameHistory.Push(game.CreateSetPoint());
#endif
                    Console.WriteLine();
                }
                catch (DuplicateGuessException)
                {
                    OutputError("You already guessed that.");
                    continue;
                }
                catch (InvalidGuessException)
                {
                    OutputError("Sorry, invalid guess.");
                    continue;
                }
            }

            if (game.Result == GameResult.Won)
            {
                Console.WriteLine("CONGRATS! YOU WON!");
            }

            if (game.Result == GameResult.Lost)
            {
                Console.WriteLine("SORRY, You lost this time. Try again!");
            }
        }

19 Source : NameFieldResolver.cs
with GNU General Public License v3.0
from arduosoft

public object Resolve(ResolveFieldContext context)
        {
            object source = context.Source;
            if (source == null)
            {
                return null;
            }
            string name = char.ToUpperInvariant(context.FieldAst.Name[0]) + context.FieldAst.Name.Substring(1);
            object value;
            if (context.SubFields != null && context.SubFields.Count > 0)
            {
                JObject src = source as JObject;
                var token = src.SelectToken($"$._metadata.rel.{name}", false);
                //value = token.Value<object>();
                if (token is JArray)
                {
                    value = token.Value<object>();
                }
                else
                {
                    value = new JArray(token.Value<object>());
                }
            }
            else
            {
                value = GetPropValue(source, name);
            }

            if (value == null)
            {
                throw new InvalidOperationException($"Expected to find property {context.FieldAst.Name} on {context.Source.GetType().Name} but it does not exist.");
            }
            return value;
        }

19 Source : TextElementRecognizer.cs
with GNU General Public License v3.0
from asimmon

private static bool AreEqualOrdinalIgnoreCase(char x, char y) => char.ToUpperInvariant(x) == char.ToUpperInvariant(y);

19 Source : CompletionList.cs
with MIT License
from AvaloniaUI

private static bool CamelCaseMatch(string text, string query)
        {
            // We take the first letter of the text regardless of whether or not it's upper case so we match
            // against camelCase text as well as PascalCase text ("cct" matches "camelCaseText")
            var theFirstLetterOfEachWord = text.AsEnumerable()
                .Take(1)
                .Concat(text.AsEnumerable().Skip(1).Where(char.IsUpper));

            var i = 0;
            foreach (var letter in theFirstLetterOfEachWord)
            {
                if (i > query.Length - 1)
                    return true;    // return true here for CamelCase partial match ("CQ" matches "CodeQualityreplacedysis")
                if (char.ToUpperInvariant(query[i]) != char.ToUpperInvariant(letter))
                    return false;
                i++;
            }
            if (i >= query.Length)
                return true;
            return false;
        }

19 Source : NaturalTextGenerator.cs
with MIT License
from azist

public static string GenerateLastName()
    {
      var rnd = rndi();

      if (rnd>0 && rnd <123000000)
        return POPULAR_LAST_NAMES[(0x7fFFFFFF & rnd) % POPULAR_LAST_NAMES.Length];


      var shrt =  rnd > 1543000000;

      string prefix;

      if (shrt)
        prefix = LAST_NAME_SUFFIXES[(0x7fFFFFFF & rndi()) % LAST_NAME_SUFFIXES.Length];
      else
      {
        do
        {
          prefix = GenerateWord(4, 8);
        }
        while(prefix.IndexOf('\'')!=-1);

        prefix = prefix.ToLowerInvariant();
      }


      var suffix = LAST_NAME_SUFFIXES[(0x7fFFFFFF & rnd) % LAST_NAME_SUFFIXES.Length];

      var reverse = !shrt && rnd<-1543000000;
      if (reverse)
      {
        var t = prefix;
        prefix = suffix;
        suffix = t;
      }


      prefix = Char.ToUpperInvariant(prefix[0]) + prefix.Substring(1).ToLowerInvariant();
      return prefix + suffix;
    }

19 Source : NaturalTextGenerator.cs
with MIT License
from azist

public static string GenerateCityName()
    {
      var rnd = rndi();

      if (rnd<-1750000000)
        return POPULAR_CITY_NAMES[(0x7fFFFFFF & rnd) % POPULAR_CITY_NAMES.Length];


      string prefix;

      if (rnd>0)
        prefix = POPULAR_FIRST_NAMES[(0x7fFFFFFF & rndi()) % POPULAR_FIRST_NAMES.Length];
      else
        prefix = POPULAR_LAST_NAMES[(0x7fFFFFFF & rndi()) % POPULAR_LAST_NAMES.Length];



      var suffix = CITY_SUFFIXES[(0x7fFFFFFF & rnd) % CITY_SUFFIXES.Length];

      prefix = Char.ToUpperInvariant(prefix[0]) + prefix.Substring(1).ToLowerInvariant();
      return prefix + suffix;
    }

19 Source : Utils.cs
with MIT License
from azist

private static bool charEqual(char a, char b, bool senseCase)
    {
      return senseCase ? a==b : Char.ToUpperInvariant(a)==Char.ToUpperInvariant(b);
    }

19 Source : NaturalTextGenerator.cs
with MIT License
from azist

public static string GenerateFirstName()
    {
      var rnd = rndi();

      if (rnd>-1500000000)
        return POPULAR_FIRST_NAMES[(0x7fFFFFFF & rnd) % POPULAR_FIRST_NAMES.Length];


      var  prefix = LAST_NAME_SUFFIXES[(0x7fFFFFFF & rndi()) % LAST_NAME_SUFFIXES.Length];



      var suffix = LAST_NAME_SUFFIXES[(0x7fFFFFFF & rnd) % LAST_NAME_SUFFIXES.Length];

      prefix = Char.ToUpperInvariant(prefix[0]) + prefix.Substring(1).ToLowerInvariant();
      return prefix + suffix;
    }

19 Source : StringExt.cs
with MIT License
from baba-s

public static string SnakeToUpperCamel( this string self )
		{
			if ( string.IsNullOrEmpty( self ) ) return self;

			return self
				.Split( new[] { '_' }, StringSplitOptions.RemoveEmptyEntries )
				.Select( s => char.ToUpperInvariant( s[ 0 ] ) + s.Substring( 1, s.Length - 1 ) )
				.Aggregate( string.Empty, ( s1, s2 ) => s1 + s2 )
			;
		}

19 Source : StringExtensions.cs
with The Unlicense
from BAndysc

public static string ToEnumName(this string str)
        {
            var sb = new StringBuilder();

            foreach (var c in str)
            {
                if (char.IsLetter(c) || char.IsDigit(c))
                    sb.Append(char.ToUpperInvariant(c));
                else if (c == ' ')
                    sb.Append('_');
            }

            return sb.ToString();
        }

19 Source : NameArg.cs
with MIT License
from bartoszlenar

private static string ConvertToreplacedleCase(string input)
        {
            if (input.Contains("_"))
            {
                input = input.Replace('_', ' ');
                input = CultureInfo.InvariantCulture.TextInfo.ToreplacedleCase(input);
            }

            foreach (var regex in _replacedleCaseRegexes)
            {
                input = regex.Replace(input, "$1 $2");
            }

            input = input.Trim();

            if (input.Length == 1)
            {
                return char.ToUpperInvariant(input[0]).ToString(CultureInfo.InvariantCulture);
            }

            return char.ToUpperInvariant(input[0]).ToString(CultureInfo.InvariantCulture) + input.Substring(1);
        }

19 Source : TemplatedString.cs
with MIT License
from bbepis

public static string ReplaceApproximateMatches( string translatedText, string translatorFriendlyKey, string key )
      {
         var cidx = 0;
         var startIdx = 0;

         for( int i = 0; i < translatedText.Length; i++ )
         {
            var c = translatedText[ i ];
            if( c == ' ' || c == ' ' ) continue;
            
            if( char.ToUpperInvariant( c ) == char.ToUpperInvariant( translatorFriendlyKey[ cidx ] ) )
            {
               if( cidx == 0 )
               {
                  startIdx = i;
               }

               cidx++;
            }
            else
            {
               cidx = 0;
               startIdx = 0;
            }

            if( cidx == translatorFriendlyKey.Length )
            {
               int endIdx = i + 1;

               var lengthOfKey = endIdx - startIdx;
               var diff = lengthOfKey - key.Length;

               translatedText = translatedText.Remove( startIdx, lengthOfKey ).Insert( startIdx, key );

               i -= diff;

               cidx = 0;
               startIdx = 0;
            }
         }

         return translatedText;
      }

19 Source : Parser.Char.cs
with MIT License
from benjamin-hodgson

public static Parser<char, char> CIChar(char character)
        {
            var theChar = char.ToLowerInvariant(character);
            var expected = ImmutableArray.Create(
                new Expected<char>(ImmutableArray.Create(char.ToUpperInvariant(character))),
                new Expected<char>(ImmutableArray.Create(char.ToLowerInvariant(character)))
            );
            return Token(c => char.ToLowerInvariant(c) == theChar)
                .WithExpected(expected);
        }

19 Source : Parser.OneOf.cs
with MIT License
from benjamin-hodgson

public static Parser<char, char> CIOneOf(IEnumerable<char> chars)
        {
            if (chars == null)
            {
                throw new ArgumentNullException(nameof(chars));
            }
            var cs = chars.Select(char.ToLowerInvariant).ToArray();
            var builder = ImmutableArray.CreateBuilder<Expected<char>>(cs.Length * 2);
            foreach (var c in cs)
            {
                builder.Add(new Expected<char>(ImmutableArray.Create(char.ToLowerInvariant(c))));
                builder.Add(new Expected<char>(ImmutableArray.Create(char.ToUpperInvariant(c))));
            }
            return Parser<char>
                .Token(c => Array.IndexOf(cs, char.ToLowerInvariant(c)) != -1)
                .WithExpected(builder.MoveToImmutable());
        }

19 Source : ZplBarcodeAnsiCodabar.cs
with MIT License
from BinaryKits

private bool IsValidCharacter(char character)
        {
            var chars = new[] { 'A', 'B', 'C', 'D' };
            return chars.Contains(char.ToUpperInvariant(character));
        }

19 Source : LabelReversePrintZplCommandAnalyzer.cs
with MIT License
from BinaryKits

public override ZplElementBase replacedyze(string zplCommand)
        {
            if (zplCommand.Length > 3)
            {
                var reverse = char.ToUpperInvariant(zplCommand[3]) == 'Y';
                this.VirtualPrinter.SetLabelReverse(reverse);
            }
            return null;
        }

19 Source : GenerateCommand.cs
with MIT License
from BionicFramework

public static string ToCamelCase(string str) {
      return string.IsNullOrEmpty(str) || str.Length < 1 ? "" : char.ToUpperInvariant(str[0]) + str.Substring(1);
    }

19 Source : CommonExtensions.cs
with MIT License
from BlazorExtensions

public static string FirstUpper(this string value)  => char.ToUpperInvariant(value[0]) + value.Substring(1);

19 Source : JsonFormatter.cs
with MIT License
from bluexo

internal static string ToJsonName(string name)
        {
            StringBuilder result = new StringBuilder(name.Length);
            bool isNextUpperCase = false;
            foreach (char ch in name)
            {
                if (ch == '_')
                {
                    isNextUpperCase = true;
                }
                else if (isNextUpperCase)
                {
                    result.Append(char.ToUpperInvariant(ch));
                    isNextUpperCase = false;
                }
                else
                {
                    result.Append(ch);
                }
            }
            return result.ToString();
        }

19 Source : Extensions.cs
with MIT License
from BoltBait

internal static char ToUpperInvariant(this char c)
        {
            return char.ToUpperInvariant(c);
        }

19 Source : Extensions.cs
with MIT License
from BoltBait

internal static string FirstCharToUpper(this string str)
        {
            if (string.IsNullOrEmpty(str) || !char.IsLetter(str[0]))
            {
                return str;
            }

            char capped = char.ToUpperInvariant(str[0]);

            if (str.Length == 1)
            {
                return capped.ToString();
            }

            return capped + str.Substring(1);
        }

19 Source : Pluralizer.cs
with Apache License 2.0
from bricelam

static string Capitalize(string word, Func<string, string> action)
        {
            var result = action(word);

            return IsCapitalized(word) && result.Length != 0
                ? char.ToUpperInvariant(result[0]) + result.Substring(1)
                : result;
        }

19 Source : TCP2_Utils.cs
with GNU General Public License v3.0
from brownhci

public static bool ShaderKeywordRadio(string header, string[] keywords, GUIContent[] labels, List<string> list, ref bool update)
	{
		var index = 0;
		for(var i = 1; i < keywords.Length; i++)
		{
			if(list.Contains(keywords[i]))
			{
				index = i;
				break;
			}
		}
		
		EditorGUI.BeginChangeCheck();
		
		//Header and rect calculations
		var hasHeader = (!string.IsNullOrEmpty(header));
		var headerRect = GUILayoutUtility.GetRect(120f, 16f, GUILayout.ExpandWidth(false));
		var r = headerRect;
		if(hasHeader)
		{
			var helpRect = headerRect;
			helpRect.width = 16;
			headerRect.width -= 16;
			headerRect.x += 16;
			var helpTopic = header.ToLowerInvariant();
			helpTopic = char.ToUpperInvariant(helpTopic[0]) + helpTopic.Substring(1);
			TCP2_GUI.HelpButton(helpRect, helpTopic);
			GUI.Label(headerRect, header, index > 0 ? EditorStyles.boldLabel : EditorStyles.label);
			r.width = ScreenWidthRetina - headerRect.width - 34f;
			r.x += headerRect.width;
		}
		else
		{
			r.width = ScreenWidthRetina - 34f;
		}
		
		for(var i = 0; i < keywords.Length; i++)
		{
			var rI = r;
			rI.width /= keywords.Length;
			rI.x += i * rI.width;
			if(GUI.Toggle(rI, index == i,labels[i], (i == 0) ? EditorStyles.miniButtonLeft : (i == keywords.Length-1) ? EditorStyles.miniButtonRight : EditorStyles.miniButtonMid))
			{
				index = i;
			}
		}
		
		if(EditorGUI.EndChangeCheck())
		{
			//Remove all other keywords and add selected
			for(var i = 0; i < keywords.Length; i++)
			{
				if(list.Contains(keywords[i]))
					list.Remove(keywords[i]);
			}
			
			if(index > 0)
			{
				list.Add(keywords[index]);
			}
			
			update = true;
		}
		
		return (index > 0);
	}

19 Source : BunitHtmlParserHelpers.cs
with MIT License
from bUnit-dev

internal static bool StartsWithElement(this string markup, string tag, int startIndex)
		{
			var matchesTag = tag.Length + 1 < markup.Length - startIndex;
			var charIndexAfterTag = tag.Length + startIndex + 1;

			if (matchesTag)
			{
				var charAfterTag = markup[charIndexAfterTag];
				matchesTag = char.IsWhiteSpace(charAfterTag) ||
							 charAfterTag == '>' ||
							 charAfterTag == '/';
			}

			// match characters in tag
			for (int i = 0; i < tag.Length && matchesTag; i++)
			{
				matchesTag = char.ToUpperInvariant(markup[startIndex + i + 1]) == tag[i];
			}

			// look for start tags end - '>'
			for (int i = charIndexAfterTag; i < markup.Length && matchesTag; i++)
			{
				if (markup[i] == '>') break;
			}

			return matchesTag;
		}

19 Source : Levenshtein.cs
with MIT License
from Butjok

public static int Distance(string a, string b, bool ignoreCase = true) {

            if (a.Length > maxLength || b.Length > maxLength)
                throw new ArgumentException();

            if (distance == null)
                distance = new int[maxLength, maxLength];

            if (a.Length == 0)
                return b.Length;
            if (b.Length == 0)
                return a.Length;

            for (var i = 0; i <= a.Length; distance[i, 0] = i++) { }
            for (var j = 0; j <= b.Length; distance[0, j] = j++) { }

            for (var i = 1; i <= a.Length; i++)
            for (var j = 1; j <= b.Length; j++) {

                var cost = (ignoreCase
                    ? char.ToUpperInvariant(b[j - 1]) == char.ToUpperInvariant(a[i - 1])
                    : b[j - 1] == a[i - 1])
                    ? 0
                    : 1;

                distance[i, j] = Mathf.Min(
                    Mathf.Min(distance[i - 1, j] + 1, distance[i, j - 1] + 1),
                    distance[i - 1, j - 1] + cost);
            }
            return distance[a.Length, b.Length];
        }

19 Source : StringExtensions.cs
with MIT License
from CacoCode

[Description("将camelCase字符串转换为pascalase字符串")]
        public static string ToPascalCase(this string str, bool invariantCulture = true)
        {
            if (string.IsNullOrWhiteSpace(str))
            {
                return str;
            }

            if (str.Length == 1)
            {
                return invariantCulture ? str.ToUpperInvariant() : str.ToUpper();
            }

            return (invariantCulture ? char.ToUpperInvariant(str[0]) : char.ToUpper(str[0])) + str.Substring(1);
        }

19 Source : WebView.cs
with MIT License
from CefNet

protected virtual bool ProcessKey(CefKeyEventType eventType, KeyEventArgs e)
		{
			if (PlatformInfo.IsWindows)
				SetWindowsKeyboardLayoutForCefUIThreadIfNeeded();

			CefEventFlags modifiers = GetCefKeyboardModifiers(e);
			Keys key = e.KeyCode;
			if (eventType == CefKeyEventType.KeyUp && key == Keys.None)
			{
				if (e.Modifiers == Keys.Shift)
				{
					key = Keys.LShiftKey;
					modifiers |= CefEventFlags.IsLeft;
				}
			}

			VirtualKeys virtualKey = key.ToVirtualKey();
			bool isSystemKey = e.Modifiers.HasFlag(Keys.Alt);

			CefBrowserHost browserHost = this.BrowserObject?.Host;
			if (browserHost != null)
			{
				var k = new CefKeyEvent();
				k.Type = eventType;
				k.Modifiers = (uint)modifiers;
				k.IsSystemKey = isSystemKey;
				k.WindowsKeyCode = (int)virtualKey;
				k.NativeKeyCode = KeycodeConverter.VirtualKeyToNativeKeyCode(virtualKey, modifiers, false);
				if (PlatformInfo.IsMacOS)
				{
					k.UnmodifiedCharacter = char.ToUpperInvariant(CefNet.Input.KeycodeConverter.TranslateVirtualKey(virtualKey, CefEventFlags.None));
					k.Character = CefNet.Input.KeycodeConverter.TranslateVirtualKey(virtualKey, modifiers);
				}
				this.BrowserObject?.Host.SendKeyEvent(k);

				if (key == Keys.Enter && eventType == CefKeyEventType.RawKeyDown)
				{
					k.Type = CefKeyEventType.Char;
					k.Character = '\r';
					k.UnmodifiedCharacter = '\r';
					this.BrowserObject?.Host.SendKeyEvent(k);
				}
			}

			if (isSystemKey)
				return true;

			// Prevent keyboard navigation using arrows and home and end keys
			if (key >= Keys.PageUp && key <= Keys.Down)
				return true;

			if (key == Keys.Tab)
				return true;

			// Allow Ctrl+A to work when the WebView control is put inside listbox.
			if (key == Keys.A && e.Modifiers.HasFlag(Keys.Control))
				return true;

			return false;
		}

19 Source : WebView.cs
with MIT License
from CefNet

protected virtual bool ProcessPreviewKey(CefKeyEventType eventType, KeyEventArgs e)
		{
			if (PlatformInfo.IsWindows)
				SetWindowsKeyboardLayoutForCefUIThreadIfNeeded();

			CefEventFlags modifiers = GetCefKeyboardModifiers(e);
			Key key = e.Key;
			if (eventType == CefKeyEventType.KeyUp && key == Key.None)
			{
				if (e.KeyModifiers == KeyModifiers.Shift)
				{
					key = Key.LeftShift;
					modifiers |= CefEventFlags.IsLeft;
				}
			}
			
			VirtualKeys virtualKey = key.ToVirtualKey();
			bool isSystemKey = (e.KeyModifiers.HasFlag(KeyModifiers.Alt) || key == Key.LeftAlt || key == Key.RightAlt);

			if (eventType == CefKeyEventType.RawKeyDown)
			{
				if ((int)virtualKey == _lastKey)
					modifiers |= CefEventFlags.IsRepeat;
				_lastKey = (int)virtualKey;
			}
			else
			{
				_lastKey = -1;
			}

			CefBrowserHost browserHost = this.BrowserObject?.Host;
			if (browserHost != null)
			{
				var k = new CefKeyEvent();
				k.Type = eventType;
				k.Modifiers = (uint)modifiers;
				k.IsSystemKey = isSystemKey;
				k.WindowsKeyCode = (int)virtualKey;
				k.NativeKeyCode = KeycodeConverter.VirtualKeyToNativeKeyCode(virtualKey, modifiers, false);
				if (PlatformInfo.IsMacOS)
				{
					k.UnmodifiedCharacter = char.ToUpperInvariant(CefNet.Input.KeycodeConverter.TranslateVirtualKey(virtualKey, CefEventFlags.None));
					k.Character = CefNet.Input.KeycodeConverter.TranslateVirtualKey(virtualKey, modifiers);
				}
				this.BrowserObject?.Host.SendKeyEvent(k);

				if (key == Key.Enter && eventType == CefKeyEventType.RawKeyDown)
				{
					k.Type = CefKeyEventType.Char;
					k.Character = '\r';
					k.UnmodifiedCharacter = '\r';
					this.BrowserObject?.Host.SendKeyEvent(k);
				}
			}

			if (isSystemKey)
				return true;

			// Prevent keyboard navigation using arrows and home and end keys
			if (key >= Key.PageUp && key <= Key.Down)
				return true;

			if (key == Key.Tab)
				return true;

			// Allow Ctrl+A to work when the WebView control is put inside listbox.
			if (key == Key.A && e.KeyModifiers.HasFlag(KeyModifiers.Control))
				return true;

			return false;
		}

19 Source : CaseConversionUtils.cs
with MIT License
from centaurus-project

public static string ConvertKebabCaseToPascalCase(string str)
        {
            var builder = new StringBuilder(str.Length);
            foreach (var c in str.Split('-'))
            {
                builder.Append(char.ToUpperInvariant(c[0]) + c.Substring(1));
            }

            return builder.ToString();
        }

See More Examples