char.ToUpper(char)

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

660 Examples 7

19 Source : ExtensionMethods.cs
with MIT License
from delight-dev

public static string CapitalizeFirstLetter(this string str)
        {
            return char.ToUpper(str[0]) + str.Substring(1);
        }

19 Source : SourceBuilder.cs
with MIT License
from DevExpress

public static SourceBuilder AppendFirstToUpperCase(this SourceBuilder builder, string str) {
            return builder.AppendChangeFirstCore(str, char.ToUpper(str[0]));
        }

19 Source : HangfireJobsService.cs
with GNU General Public License v3.0
from Devscord-Team

private string FixJobName(string name)
        {
            var result = new List<char>();
            for (var i = 0; i < name.Length; i++)
            {
                var letter = name[i];
                if (i > 0 && letter == char.ToUpper(letter))
                {
                    result.Add(' ');
                }
                result.Add(letter);
            }
            return new string(result.ToArray());
        }

19 Source : Lexer.cs
with MIT License
from Didstopia

public Symbol ScanHexadecimalString()
        {
            Debug.replacedert(_currChar == Chars.Less);

            _token = new StringBuilder();
            char[] hex = new char[2];
            ScanNextChar(true);
            while (true)
            {
                MoveToNonWhiteSpace();
                if (_currChar == '>')
                {
                    ScanNextChar(true);
                    break;
                }
                if (char.IsLetterOrDigit(_currChar))
                {
                    hex[0] = char.ToUpper(_currChar);
                    hex[1] = char.ToUpper(_nextChar);
                    int ch = int.Parse(new string(hex), NumberStyles.AllowHexSpecifier);
                    _token.Append(Convert.ToChar(ch));
                    ScanNextChar(true);
                    ScanNextChar(true);
                }
            }
            string chars = _token.ToString();
            int count = chars.Length;
            if (count > 2 && chars[0] == (char)0xFE && chars[1] == (char)0xFF)
            {
                Debug.replacedert(count % 2 == 0);
                _token.Length = 0;
                for (int idx = 2; idx < count; idx += 2)
                    _token.Append((char)(chars[idx] * 256 + chars[idx + 1]));
                return _symbol = Symbol.UnicodeHexString;
            }
            return _symbol = Symbol.HexString;
        }

19 Source : ContactsTextFieldVisualizer.cs
with Apache License 2.0
from dilmerv

void OnGUI()
        {
            if (!_isSelected)
            {
                return;
            }

            Event e = Event.current;
            if (e.type == EventType.KeyDown)
            {
                if (e.keyCode == KeyCode.Backspace)
                {
                    if (_content.Length > 0)
                    {
                        _content = _content.Substring(0, _content.Length - 1);
                    }
                }
                else if (!Char.IsControl(e.character))
                {
                    if (e.modifiers == EventModifiers.Shift)
                    {
                        _content += char.ToUpper(e.character);
                    }
                    else
                    {
                        _content += e.character;
                    }
                }
            }
        }

19 Source : Saml2StringExtensions.cs
with MIT License
from dina-heidar

public static string UpperCaseUrlEncode(this string value)
        {
            var result = new StringBuilder(value);
            for (var i = 0; i < result.Length; i++)
                if (result[i] == '%')
                {
                    result[++i] = char.ToUpper(result[i]);
                    result[++i] = char.ToUpper(result[i]);
                }
            return result.ToString();
        }

19 Source : FactionPair.cs
with MIT License
from DiplomacyTeam

private static int CalculateHash(string s)
        {
            var num = 0;

            foreach (var t in s)
            {
                num *= 17;
                num += char.ToUpper(t) - '0';
            }

            return num;
        }

19 Source : SuggestSourceViewModel.cs
with MIT License
from Dirkster99

private SuggestQueryResultModel ListDrives(string input)
		{
			if (string.IsNullOrEmpty(input))
				return GetLogicalDrives();

			if (input.Length == 1)
			{
				if (char.ToUpper(input[0]) >= 'A' && char.ToUpper(input[0]) <= 'Z')
				{
					// Check if we know this drive and list it with sub-folders if we do
					var testDrive = input + ":\\";
					var folders = GetLogicalDriveOrSubDirs(testDrive, input);
					if (folders != null)
						return folders;
				}
			}

			if (input.Length == 2)
			{
				if (char.ToUpper(input[1]) == ':' &&
					char.ToUpper(input[0]) >= 'A' && char.ToUpper(input[0]) <= 'Z')
				{
					// Check if we know this drive and list it with sub-folders if we do
					var testDrive = input + "\\";
					var folders = GetLogicalDriveOrSubDirs(testDrive, input);
					if (folders != null)
						return folders;
				}
				else
				{
					return new SuggestQueryResultModel(new List<object>(), false);
				}
			}

			if (input.Length == 3)
			{
				if (char.ToUpper(input[1]) == ':' &&
					char.ToUpper(input[2]) == '\\' &&
					char.ToUpper(input[0]) >= 'A' && char.ToUpper(input[0]) <= 'Z')
				{
					// Check if we know this drive and list it with sub-folders if we do
					var folders = GetLogicalDriveOrSubDirs(input, input);
					if (folders != null)
						return folders;
				}
			}

			return GetLogicalDrives();
		}

19 Source : PathModel.cs
with MIT License
from Dirkster99

public static string NormalizePath(string dirOrfilePath)
		{
			if (string.IsNullOrEmpty(dirOrfilePath) == true)
				return null;

			// The dirinfo constructor will not work with 'C:' but does work with 'C:\'
			if (dirOrfilePath.Length < 2)
				return null;

			if (dirOrfilePath.Length == 2)
			{
				if (dirOrfilePath[dirOrfilePath.Length - 1] == ':')
					return dirOrfilePath + System.IO.Path.DirectorySeparatorChar;
			}

			if (dirOrfilePath.Length == 3)
			{
				if (dirOrfilePath[dirOrfilePath.Length - 2] == ':' &&
					dirOrfilePath[dirOrfilePath.Length - 1] == System.IO.Path.DirectorySeparatorChar)
					return dirOrfilePath;

				return "" + dirOrfilePath[0] + dirOrfilePath[1] +
							System.IO.Path.DirectorySeparatorChar + dirOrfilePath[2];
			}

			// Insert a backslash in 3rd character position if not already present
			// C:Temp\myfile -> C:\Temp\myfile
			if (dirOrfilePath.Length >= 3)
			{
				if (char.ToUpper(dirOrfilePath[0]) >= 'A' && char.ToUpper(dirOrfilePath[0]) <= 'Z' &&
					dirOrfilePath[1] == ':' &&
					dirOrfilePath[2] != '\\')
				{
					dirOrfilePath = dirOrfilePath.Substring(0, 2) + "\\" + dirOrfilePath.Substring(2);
				}
			}

			// This will normalize directory and drive references into 'C:' or 'C:\Temp'
			if (dirOrfilePath[dirOrfilePath.Length - 1] == System.IO.Path.DirectorySeparatorChar)
				dirOrfilePath = dirOrfilePath.Trim(System.IO.Path.DirectorySeparatorChar);

			return dirOrfilePath;
		}

19 Source : PathModel.cs
with MIT License
from Dirkster99

public static string NormalizePath(string dirOrfilePath)
        {
            if (string.IsNullOrEmpty(dirOrfilePath) == true)
                return null;

            // The dirinfo constructor will not work with 'C:' but does work with 'C:\'
            if (dirOrfilePath.Length < 2)
                return null;

            if (dirOrfilePath.Length == 2)
            {
                if (dirOrfilePath[dirOrfilePath.Length - 1] == ':')
                    return dirOrfilePath + System.IO.Path.DirectorySeparatorChar;
            }

            if (dirOrfilePath.Length == 3)
            {
                if (dirOrfilePath[dirOrfilePath.Length - 2] == ':' &&
                    dirOrfilePath[dirOrfilePath.Length - 1] == System.IO.Path.DirectorySeparatorChar)
                    return dirOrfilePath;

                return "" + dirOrfilePath[0] + dirOrfilePath[1] +
                            System.IO.Path.DirectorySeparatorChar + dirOrfilePath[2];
            }

            // Insert a backslash in 3rd character position if not already present
            // C:Temp\myfile -> C:\Temp\myfile
            if (dirOrfilePath.Length >= 3)
            {
                if (char.ToUpper(dirOrfilePath[0]) >= 'A' && char.ToUpper(dirOrfilePath[0]) <= 'Z' &&
                    dirOrfilePath[1] == ':' &&
                    dirOrfilePath[2] != '\\')
                {
                    dirOrfilePath = dirOrfilePath.Substring(0, 2) + "\\" + dirOrfilePath.Substring(2);
                }
            }

            // This will normalize directory and drive references into 'C:' or 'C:\Temp'
            if (dirOrfilePath[dirOrfilePath.Length - 1] == System.IO.Path.DirectorySeparatorChar)
                dirOrfilePath = dirOrfilePath.Trim(System.IO.Path.DirectorySeparatorChar);

            return dirOrfilePath;
        }

19 Source : DirectoryHelper.cs
with MIT License
from Dirkster99

public static char TryGetUpper(this string value, int index)
        {
            return char.ToUpper(value.ElementAtOrDefault(index));
        }

19 Source : PathModel.cs
with MIT License
from Dirkster99

public static string NormalizePath(string dirOrFilePath)
        {
            if (dirOrFilePath == null)
                return null;

            // The dirinfo constructor will not work with 'C:' but does work with 'C:\'
            if (dirOrFilePath.Length == 2)
            {
                if (dirOrFilePath[dirOrFilePath.Length - 1] == ':')
                    dirOrFilePath += System.IO.Path.DirectorySeparatorChar;
            }
            else
            {
                if (dirOrFilePath.Length > 2)
                {
                    if (char.ToUpper(dirOrFilePath[0]) >= 'A' && char.ToUpper(dirOrFilePath[0]) <= 'Z' &&
                        dirOrFilePath[1] == ':' &&
                        dirOrFilePath[2] != '\\')
                    {
                        dirOrFilePath = dirOrFilePath.Substring(0, 2) + "\\" + dirOrFilePath.Substring(2);
                    }
                }
            }

            return dirOrFilePath;
        }

19 Source : DispatchMain.cs
with GNU General Public License v3.0
from DispatchSystems

private void OnFirstNameKeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar))
                e.Handled = true;
            if (char.IsLetter(e.KeyChar))
                e.KeyChar = firstName.Text.Length == 0 ? char.ToUpper(e.KeyChar) : char.ToLower(e.KeyChar);
        }

19 Source : DispatchMain.cs
with GNU General Public License v3.0
from DispatchSystems

private void OnPlateKeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsControl(e.KeyChar) && !char.IsLetterOrDigit(e.KeyChar) && e.KeyChar != ' ' || plate.Text.Length >= 8 && !e.KeyChar.Equals('\b'))
            {
                e.Handled = true;
                
            }
            if (char.IsLetter(e.KeyChar))
                e.KeyChar = char.ToUpper(e.KeyChar);
        }

19 Source : DispatchMain.cs
with GNU General Public License v3.0
from DispatchSystems

private void OnLastNameKeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar))
                e.Handled = true;
            if (char.IsLetter(e.KeyChar))
                e.KeyChar = lastName.Text.Length == 0 ? char.ToUpper(e.KeyChar) : char.ToLower(e.KeyChar);
                
        }

19 Source : TraceryUnparser.cs
with MIT License
from disunity-hq

[Factory]
        public static Func<string, Unparser> UnparserFactory(IServiceProvider di) {
            var logger = di.GetRequiredService<ILogger<TraceryUnparser>>();
            var config = di.GetRequiredService<IConfiguration>();
            var slugifier = di.GetRequiredService<ISlugifier>();
            var grammarPath = config.GetValue<string>("Database:TraceryGrammarPath");

            string Capitalize(string s) {
                if (string.IsNullOrEmpty(s)) {
                    return s;
                }

                var result = char.ToUpper(s[0]).ToString();

                if (s.Length > 1) {
                    result += s.Substring(1);
                }

                return result;
            }

            string replacedleCase(string s) {
                var parts = s.Split(null)
                             .Where(p => p.Any())
                             .Select(p => char.ToUpper(p[0]) + p.Substring(1));

                return String.Join(" ", parts);
            }

            return filename => {
                var fullPath = Path.Combine(grammarPath, filename);
                var grammar = Grammar.FromFile(fullPath);
                var unparser = new Unparser(grammar);

                unparser.Modifiers["capitalize"] = Capitalize;
                unparser.Modifiers["replacedle"] = replacedleCase;
                unparser.Modifiers["slug"] = slugifier.Slugify;

                return unparser;
            };
        }

19 Source : Condition.cs
with MIT License
from Dogwei

public static bool TryParse(ITable table, string expression, out Condition condition)
        {
            const char match_begin = '[';
            const char match_end = ']';

            condition = default;

            if (string.IsNullOrEmpty(expression))
            {
                return false;
            }

            if (expression[0] != match_begin)
            {
                return false;
            }

            var match_length = expression.IndexOf(match_end);

            if (match_length < 0)
            {
                return false;
            }

            var index = "0";
            var type = ConditionTypes.And;

            var match_index = 1;

            var index_length = 0;

            for (int i = match_index; i < match_length; i++)
            {
                if (expression[i] >= '0' && expression[i] <= '9')
                {
                    ++index_length;
                }
                else
                {
                    break;
                }
            }

            if (index_length >= 1)
            {
                index = expression.Substring(match_index, index_length);
            }

            match_index += index_length;

            var type_length = 0;

            switch (char.ToUpper(expression[match_index]))
            {
                case 'A':
                    if (expression.IndexOf("AND", StringComparison.OrdinalIgnoreCase) == match_index)
                    {
                        type_length += 3;
                    }
                    break;
                case 'O':
                    if (expression.IndexOf("OR", StringComparison.OrdinalIgnoreCase) == match_index)
                    {
                        type_length += 2;
                    }
                    break;
                case '&':
                case '|':
                    ++type_length;
                    break;
            }

            if (type_length >= 1)
            {
                switch (expression.Substring(match_index, type_length).ToUpper())
                {
                    case "AND":
                    case "&":
                    case "&&":
                        type = ConditionTypes.And;
                        break;
                    case "OR":
                    case "|":
                    case "||":
                        type = ConditionTypes.Or;
                        break;
                    default:
                        type_length = 0;
                        break;
                }
            }

            match_index += type_length;

            var comparison_length = 0;

            for (int i = match_index; i < match_length; i++)
            {
                switch (expression[i])
                {
                    case var lower when lower >= 'a' && lower <= 'z':
                    case var upper when upper >= 'A' && upper <= 'Z':
                    case '>':
                    case '<':
                    case '=':
                    case '!':
                        ++comparison_length;
                        continue;
                }

                break;
            }

            if (!(comparison_length >= 1))
            {
                return false;
            }

            if (!ComparisonAttribute.TryGetComparison(expression.Substring(match_index, comparison_length), out var comparison))
            {
                return false;
            }

            match_index += comparison_length;

            if (match_index != match_length)
            {
                return false;
            }

            var equal_index = expression.IndexOf('=', match_length);

            string before;
            string after = null;

            if (equal_index >= 0)
            {
                before = expression.Substring(match_length + 1, equal_index - match_length - 1);
                after = expression.Substring(equal_index + 1);
            }
            else
            {
                before = expression.Substring(match_length + 1);
            }

            condition = new Condition(index, type, comparison, new Column(table, before), SqlHelper.ValueOf(after));

            return true;
        }

19 Source : StringExtensions.cs
with MIT License
from dotnet-ad

public static string FirstLetterToUpper(this string str)
		{
			if (str == null)
				return null;

			if (str.Length > 1)
				return char.ToUpper(str[0]) + str.Substring(1);

			return str.ToUpper();
		}

19 Source : ConsoleImprovedTests.cs
with MIT License
from dotnet-shell

public ConsoleKeyInfo ReadKey()
        {
            var keyEx = keys.Dequeue();

            char final;
            if (keyEx.Key.Value == ConsoleKey.Tab)
            {
                final = '\t';
            }
            else if (keyEx.Key.Value == ConsoleKey.Spacebar)
            {
                final = ' ';
            }
            else if (keyEx.Key.Value == ConsoleKey.Enter)
            {
                final = '\r';
            }
            else if (keyEx.Key.Value == ConsoleKey.Backspace || 
                     keyEx.Key.Value == ConsoleKey.Home ||
                     keyEx.Key.Value == ConsoleKey.End ||
                     keyEx.Key.Value == ConsoleKey.LeftArrow ||
                     keyEx.Key.Value == ConsoleKey.RightArrow)
            {
                final = '\0';
            }
            else if (keyEx.Key.Value == ConsoleKey.OemPeriod)
            {
                final = '.';
            }
            else
            {
                final = char.ToLower(keyEx.Key.Value.ToString()[0]);
                if (keyEx.Modifier == ConsoleModifiers.Shift)
                {
                    final = char.ToUpper(final);
                }
            }

            CursorLeft++;
            return new ConsoleKeyInfo(final, keyEx.Key.Value, keyEx.Modifier == ConsoleModifiers.Shift, keyEx.Modifier == ConsoleModifiers.Alt, keyEx.Modifier == ConsoleModifiers.Control);
        }

19 Source : ImportedControlGenerator.cs
with MIT License
from dotnet-standard-ui

private static bool IsStandardUIInterface(ITypeSymbol type)
        {
            string typeName = type.Name;

            return typeName.Length > 1 && typeName[0] == 'I' && typeName[1] == char.ToUpper(typeName[1]);
        }

19 Source : Pluralizer.cs
with MIT License
from dotnet-toolbelt

internal string RestoreCase(string originalWord, string newWord)
        {
            // Tokens are an exact match.
            if (originalWord == newWord)
                return newWord;

            // Upper cased words. E.g. "HELLO".
            if (originalWord == originalWord.ToUpper())
                return newWord.ToUpper();

            // replacedle cased words. E.g. "replacedle".
            if (originalWord[0] == char.ToUpper(originalWord[0]))
                return char.ToUpper(newWord[0]) + newWord.Substring(1);

            // Lower cased words. E.g. "test".
            return newWord.ToLower();
        }

19 Source : AttributeAnalyzer.cs
with MIT License
from DotNetAnalyzers

private static bool ShouldRenameController(PathSegment segment, UrlAttribute urlAttribute, SyntaxNodereplacedysisContext context, out Replacement<Location> replacement)
        {
            if (urlAttribute.UrlTemplate is { } template &&
                template.Path.TryLast(x => x.Parameter is null, out var last) &&
                last == segment &&
                segment.Span.Length > 0 &&
                segment.Span[0] != '[' &&
                context.ContainingSymbol is INamedTypeSymbol containingType &&
                urlAttribute.TryGetParentMember(out var parent) &&
                parent is ClreplacedDeclarationSyntax clreplacedDeclaration)
            {
                var builder = ClreplacedName();
                if (builder != null)
                {
                    if (Equals(builder, containingType.Name))
                    {
                        _ = builder.Clear()
                                   .Return();
                        replacement = default;
                        return false;
                    }

                    replacement = new Replacement<Location>(clreplacedDeclaration.Identifier.GetLocation(), builder.Return());
                    return true;
                }
            }

            replacement = default;
            return false;

            StringBuilderPool.PooledStringBuilder? ClreplacedName()
            {
                var builder = StringBuilderPool.Borrow()
                                               .Append(char.ToUpper(segment.Span[0], CultureInfo.InvariantCulture));
                for (var i = 1; i < segment.Span.Length; i++)
                {
                    var c = segment.Span[i];
                    if (c == '-')
                    {
                        if (i == segment.Span.Length - 2)
                        {
                            _ = builder.Clear()
                                       .Return();
                            return null;
                        }

                        i++;
                        _ = builder.Append(char.ToUpper(segment.Span[i], CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        _ = builder.Append(c);
                    }
                }

                return builder.Append("Controller");
            }

            bool Equals(StringBuilderPool.PooledStringBuilder x, string y)
            {
                if (x.Length == y.Length)
                {
                    for (var i = 0; i < x.Length; i++)
                    {
                        if (x[i] != y[i])
                        {
                            return false;
                        }
                    }

                    return true;
                }

                return false;
            }
        }

19 Source : PropertyDeclarationAnalyzer.cs
with MIT License
from DotNetAnalyzers

private static bool HasMatchingName(IFieldSymbol backingField, IPropertySymbol property)
        {
            if (backingField.IsStatic || backingField.IsConst)
            {
                return true;
            }

            if (property.ExplicitInterfaceImplementations.TryFirst(out var explicitProperty))
            {
                return HasMatchingName(backingField, explicitProperty);
            }

            if (backingField.Name.Length < property.Name.Length)
            {
                return false;
            }

            var diff = backingField.Name.Length - property.Name.Length;
            for (var pi = property.Name.Length - 1; pi >= 0; pi--)
            {
                var fi = pi + diff;
                if (pi == 0)
                {
                    if (char.ToLower(property.Name[pi], CultureInfo.InvariantCulture) != backingField.Name[fi])
                    {
                        return false;
                    }

                    return fi switch
                    {
                        0 => true,
                        1 => backingField.Name[0] == '_' ||
                             backingField.Name[0] == '@',
                        _ => false,
                    };
                }

                if (property.Name[pi] != backingField.Name[fi])
                {
                    if (!char.IsUpper(property.Name[pi - 1]) ||
                        char.ToUpper(backingField.Name[fi], CultureInfo.InvariantCulture) != property.Name[pi])
                    {
                        return false;
                    }
                }
            }

19 Source : OptimizedHexConversionTests.cs
with GNU General Public License v3.0
from Dotsarecool

[Fact]
        public static void TestHexRange()
        {
            for (var c = '\0'; c < 255; ++c)
            {
                if (validHexChars.Contains(char.ToUpper(c)))
                {
                    replacedert.Equal(Convert.ToInt32(c.ToString(), 16), ByteUtil.ByteParseHex1(c));
                }
                else
                {
                    replacedert.Throws<InvalidDataException>(() => ByteUtil.ByteParseHex1(c));    
                }
                
            }
        }

19 Source : SIPAccount.cs
with BSD 2-Clause "Simplified" License
from double-hi

private string GeFirstUpperString(string input)
        {
            if (!input.IsNullOrBlank() && input.Length > 1)
            {
                return char.ToUpper(input[0]) + input.Substring(1).ToLower();
            }
            else if (input.Length > 0)
            {
                return input.ToUpper();
            }
            return "";
        }

19 Source : Extensions.cs
with MIT License
from dshe

internal static string ToPascal(this string source)
        {
            if (source is null)
                throw new ArgumentNullException(nameof(source));
            if (source == "")
                return "";
            char[] chars = source.ToCharArray();
            chars[0] = Char.ToUpper(chars[0]);
            return new string(chars);
        }

19 Source : AbpFunctions.cs
with MIT License
from EasyAbp

public static string GetHttpVerb(MethodInfo method)
        {
            var verbs = HttpMethodHelper.ConventionalPrefixes.Keys.Select(prefix => $"Http{prefix}").ToList();
            var verb = method.Attributes.FirstOrDefault(attr => verbs.Contains(attr, StringComparer.InvariantCultureIgnoreCase));
            if (verb == null)
            {
                verb = HttpMethodHelper.GetConventionalVerbForMethodName(method.Name);
                return $"Http{Char.ToUpper(verb[0])}{verb.Substring(1).ToLower()}";
            }
            else
            {
                return verb;
            }
        }

19 Source : CSVClassFileGenerator.razor.cs
with MIT License
from egil

static string StringToValidPropertyName(string s)
		{
			s = s.Trim();
			s = char.IsLetter(s[0]) ? char.ToUpper(s[0]) + s.Substring(1) : s;
			s = char.IsDigit(s.Trim()[0]) ? "_" + s : s;
			s = new string(s.Select(ch => char.IsDigit(ch) || char.IsLetter(ch) ? ch : '_').ToArray());
			return s;
		}

19 Source : CSVGenerator.cs
with MIT License
from egil

static string StringToValidPropertyName(string s)
        {
            s = s.Trim();
            s = char.IsLetter(s[0]) ? char.ToUpper(s[0]) + s.Substring(1) : s;
            s = char.IsDigit(s.Trim()[0]) ? "_" + s : s;
            s = new string(s.Select(ch => char.IsDigit(ch) || char.IsLetter(ch) ? ch : '_').ToArray());
            return s;
        }

19 Source : FileTypeResolver.cs
with MIT License
from egorozh

public string GetFileType(FileSystemInfo info)
    {   
        return info switch
        {
            DirectoryInfo directoryInfo => Strings.FileVm_DirectoryTypeName,
            FileInfo fileInfo => fileInfo.Extension[1..].ToUpper(),
            _ => throw new ArgumentOutOfRangeException(nameof(info))
        };

19 Source : Move.cs
with GNU General Public License v3.0
from ekmadsen

public static ulong ParseStandardAlgebraic(Board board, string standardAlgebraic)
    {
        var move = Null;
        // Remove check and checkmate symbols.
        var standardAlgebraicNoCheck = standardAlgebraic.TrimEnd("+#".ToCharArray());
        // ReSharper disable once SwitchStatementMissingSomeCases
        switch (standardAlgebraicNoCheck)
        {
            case "O-O-O":
            case "0-0-0":
                // Castle Queenside
                SetFrom(ref move, Board.CastleFromSquares[(int)board.CurrentPosition.ColorToMove]);
                SetTo(ref move, Board.CastleToSquares[(int)board.CurrentPosition.ColorToMove][(int)BoardSide.Queen]);
                if (!board.ValidateMove(ref move)) throw new Exception($"Move {standardAlgebraic} is illegal in position {board.CurrentPosition.ToFen()}.");
                return move;
            case "O-O":
            case "0-0":
                // Castle Kingside
                SetFrom(ref move, Board.CastleFromSquares[(int)board.CurrentPosition.ColorToMove]);
                SetTo(ref move, Board.CastleToSquares[(int)board.CurrentPosition.ColorToMove][(int)BoardSide.King]);
                if (!board.ValidateMove(ref move)) throw new Exception($"Move {standardAlgebraic} is illegal in position {board.CurrentPosition.ToFen()}.");
                return move;
        }
        var length = standardAlgebraicNoCheck.Length;
        var fromFile = -1;
        var fromRank = -1;
        var promotedPiece = Piece.None;
        Piece piece;
        Square toSquare;
        if (char.IsLower(standardAlgebraicNoCheck, 0))
        {
            // Pawn Move
            piece = PieceHelper.GetPieceOfColor(ColorlessPiece.Pawn, board.CurrentPosition.ColorToMove);
            fromFile = Board.Files[(int)Board.GetSquare($"{standardAlgebraicNoCheck[0]}1")];
            switch (length)
            {
                case 2:
                    // Pawn Move
                    toSquare = Board.GetSquare(standardAlgebraicNoCheck);
                    break;
                case 4 when standardAlgebraicNoCheck[1] == 'x':
                    // Pawn Capture
                    toSquare = Board.GetSquare(standardAlgebraicNoCheck.Substring(2, 2));
                    break;
                case 4 when standardAlgebraicNoCheck[2] == '=':
                    // Pawn promotion.  Set case of promoted piece character based on side to move.
                    toSquare = Board.GetSquare(standardAlgebraicNoCheck.Substring(0, 2));
                    promotedPiece = PieceHelper.ParseChar(board.CurrentPosition.ColorToMove == Color.White
                        ? char.ToUpper(standardAlgebraicNoCheck[length - 1])
                        : char.ToLower(standardAlgebraicNoCheck[length - 1]));
                    break;
                case 6:
                    // Pawn promotion with capture.  Set case of promoted piece character based on side to move.
                    toSquare = Board.GetSquare(standardAlgebraicNoCheck.Substring(2, 2));
                    promotedPiece = PieceHelper.ParseChar(board.CurrentPosition.ColorToMove == Color.White
                        ? char.ToUpper(standardAlgebraicNoCheck[length - 1])
                        : char.ToLower(standardAlgebraicNoCheck[length - 1]));
                    break;
                default:
                    throw new Exception($"Move {standardAlgebraic} is illegal in position {board.CurrentPosition.ToFen()}.");
            }
        }
        else
        {
            // Piece Move
            piece = PieceHelper.ParseChar(board.CurrentPosition.ColorToMove == Color.White
                ? char.ToUpper(standardAlgebraicNoCheck[0])
                : char.ToLower(standardAlgebraicNoCheck[0]));
            // ReSharper disable once ConvertIfStatementToSwitchStatement
            if (standardAlgebraicNoCheck[1] == 'x')
            {
                // Piece Capture
                var square = standardAlgebraicNoCheck.Substring(2, 2);
                toSquare = Board.GetSquare(square);
            }
            else if (standardAlgebraicNoCheck[2] == 'x')
            {
                // Piece Capture with Disambiguation
                var square = standardAlgebraicNoCheck.Substring(3, 2);
                toSquare = Board.GetSquare(square);
                if (char.IsLetter(standardAlgebraicNoCheck[1])) fromFile = Board.Files[(int)Board.GetSquare($"{standardAlgebraicNoCheck[1]}1")]; // Piece disambiguated by file.
                else fromRank = Board.Ranks[(int)Color.White][(int)Board.GetSquare($"a{standardAlgebraicNoCheck[1]}")]; // Piece disambiguated by rank.
            }
            else if ((length > 3) && (standardAlgebraicNoCheck[3] == 'x'))
            {
                // Piece Capture with From Square Specified
                var square = standardAlgebraicNoCheck.Substring(4, 2);
                toSquare = Board.GetSquare(square);
                fromFile = Board.Files[(int)Board.GetSquare($"{standardAlgebraicNoCheck[1]}1")];
                fromRank = Board.Ranks[(int)Color.White][(int)Board.GetSquare($"a{standardAlgebraicNoCheck[2]}")];
            }
            else if (length == 3)
            {
                // Piece Move
                var square = standardAlgebraicNoCheck.Substring(1, 2);
                toSquare = Board.GetSquare(square);
            }
            else if (length == 4)
            {
                // Piece Move with Disambiguation
                var square = standardAlgebraicNoCheck.Substring(2, 2);
                toSquare = Board.GetSquare(square);
                if (char.IsLetter(standardAlgebraicNoCheck[1])) fromFile = Board.Files[(int)Board.GetSquare($"{standardAlgebraicNoCheck[1]}1")]; // Piece disambiguated by file.
                else fromRank = Board.Ranks[(int)Color.White][(int)Board.GetSquare($"a{standardAlgebraicNoCheck[1]}")]; // Piece disambiguated by rank.
            }
            else if (length == 5)
            {
                // Piece Move with From Square Specified
                var square = standardAlgebraicNoCheck.Substring(3, 2);
                toSquare = Board.GetSquare(square);
                fromFile = Board.Files[(int)Board.GetSquare($"{standardAlgebraicNoCheck[1]}1")];
                fromRank = Board.Ranks[(int)Color.White][(int)Board.GetSquare($"a{standardAlgebraicNoCheck[2]}")];
            }
            else throw new Exception($"{standardAlgebraic} move not supported.");
        }
        board.CurrentPosition.GenerateMoves();
        for (var moveIndex = 0; moveIndex < board.CurrentPosition.MoveIndex; moveIndex++)
        {
            move = board.CurrentPosition.Moves[moveIndex];
            if (!board.IsMoveLegal(ref move)) continue; // Skip illegal move.
            var movePiece = board.CurrentPosition.GetPiece(From(move));
            if (movePiece != piece) continue; // Wrong Piece
            var moveToSquare = To(move);
            if (moveToSquare != toSquare) continue; // Wrong Square
            var movePromotedPiece = PromotedPiece(move);
            if (movePromotedPiece != promotedPiece) continue; // Wrong Promoted Piece
            if (fromFile >= 0)
            {
                // Piece disambiguated by file.
                var moveFromFile = Board.Files[(int)From(move)];
                if (moveFromFile != fromFile) continue; // Wrong File
            }
            if (fromRank >= 0)
            {
                // Piece disambiguated by rank.
                var moveFromRank = Board.Ranks[(int)Color.White][(int)From(move)];
                if (moveFromRank != fromRank) continue; // Wrong Rank
            }
            if (!board.ValidateMove(ref move)) throw new Exception($"Move {standardAlgebraic} is illegal in position {board.CurrentPosition.ToFen()}.");
            return move;
        }
        throw new Exception($"Failed to parse {standardAlgebraic} standard algebraic notation move.");
    }

19 Source : Move.cs
with GNU General Public License v3.0
from ekmadsen

public static ulong ParseLongAlgebraic(string longAlgebraic, Color colorToMove)
    {
        var fromSquare = Board.GetSquare(longAlgebraic.Substring(0, 2));
        var toSquare = Board.GetSquare(longAlgebraic.Substring(2, 2));
        // Set case of promoted piece character based on side to move.
        var promotedPiece = longAlgebraic.Length == 5
            ? PieceHelper.ParseChar(colorToMove == Color.White ? char.ToUpper(longAlgebraic[4]) : char.ToLower(longAlgebraic[4]))
            : Piece.None;
        var move = Null;
        SetFrom(ref move, fromSquare);
        SetTo(ref move, toSquare);
        SetPromotedPiece(ref move, promotedPiece);
        return move;
    }

19 Source : FilterEditorForm.cs
with GNU General Public License v3.0
from elecyb

private void tx_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Escape || e.KeyChar == (char)Keys.Back)
                return;

            if (!int.TryParse(e.KeyChar.ToString(), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int result))
            {
                e.Handled = true;
            }
            else
            {
                e.KeyChar = Char.ToUpper(e.KeyChar);
            }
        }

19 Source : StringExtensions.cs
with MIT License
from EmitKnowledge

public static string FirstLetterToUpperCase(this string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return string.Empty;
            }
            char[] a = s.ToCharArray();
            a[0] = char.ToUpper(a[0]);
            return new string(a);
        }

19 Source : Extensions.cs
with GNU Lesser General Public License v3.0
from Energizers

public static bool FuzzyMatch(this string stringToSearch, string pattern, out int outScore)
        {
            // Score consts
            const int adjacencyBonus = 5; // bonus for adjacent matches
            const int separatorBonus = 10; // bonus if match occurs after a separator
            const int camelBonus = 10;     // bonus if match is uppercase and prev is lower

            const int leadingLetterPenalty = -3;    // penalty applied for every letter in stringToSearch before the first match
            const int maxLeadingLetterPenalty = -9; // maximum penalty for leading letters
            const int unmatchedLetterPenalty = -1;  // penalty for every letter that doesn't matter

            // Loop variables
            int score = 0;
            int patternIdx = 0;
            int patternLength = pattern.Length;
            int strIdx = 0;
            int strLength = stringToSearch.Length;
            bool prevMatched = false;
            bool prevLower = false;
            bool prevSeparator = true; // true if first letter match gets separator bonus

            // Use "best" matched letter if multiple string letters match the pattern
            char? bestLetter = null;
            char? bestLower = null;
            int? bestLetterIdx = null;
            int bestLetterScore = 0;

            List<int> matchedIndices = new List<int>();

            // Loop over strings
            while (strIdx != strLength)
            {
                char? patternChar = patternIdx != patternLength ? pattern[patternIdx] as char? : null;
                char strChar = stringToSearch[strIdx];

                char? patternLower = patternChar != null ? char.ToLower((char)patternChar) as char? : null;
                char strLower = char.ToLower(strChar);
                char strUpper = char.ToUpper(strChar);

                bool nextMatch = patternChar != null && patternLower == strLower;
                bool rematch = bestLetter != null && bestLower == strLower;

                bool advanced = nextMatch && bestLetter != null;
                bool patternRepeat = bestLetter != null && patternChar != null && bestLower == patternLower;
                if (advanced || patternRepeat)
                {
                    score += bestLetterScore;
                    matchedIndices.Add((int)bestLetterIdx);
                    bestLetter = null;
                    bestLower = null;
                    bestLetterIdx = null;
                    bestLetterScore = 0;
                }

                if (nextMatch || rematch)
                {
                    int newScore = 0;

                    // Apply penalty for each letter before the first pattern match
                    // Note: Math.Max because penalties are negative values. So max is smallest penalty.
                    if (patternIdx == 0)
                    {
                        int penalty = Math.Max(strIdx * leadingLetterPenalty, maxLeadingLetterPenalty);
                        score += penalty;
                    }

                    // Apply bonus for consecutive bonuses
                    if (prevMatched)
                        newScore += adjacencyBonus;

                    // Apply bonus for matches after a separator
                    if (prevSeparator)
                        newScore += separatorBonus;

                    // Apply bonus across camel case boundaries. Includes "clever" isLetter check.
                    if (prevLower && strChar == strUpper && strLower != strUpper)
                        newScore += camelBonus;

                    // Update pattern index IF the next pattern letter was matched
                    if (nextMatch)
                        ++patternIdx;

                    // Update best letter in stringToSearch which may be for a "next" letter or a "rematch"
                    if (newScore >= bestLetterScore)
                    {
                        // Apply penalty for now skipped letter
                        if (bestLetter != null)
                            score += unmatchedLetterPenalty;

                        bestLetter = strChar;
                        bestLower = char.ToLower((char)bestLetter);
                        bestLetterIdx = strIdx;
                        bestLetterScore = newScore;
                    }

                    prevMatched = true;
                }
                else
                {
                    score += unmatchedLetterPenalty;
                    prevMatched = false;
                }

                // Includes "clever" isLetter check.
                prevLower = strChar == strLower && strLower != strUpper;
                prevSeparator = strChar == '_' || strChar == ' ';

                ++strIdx;
            }

            // Apply score for last match
            if (bestLetter != null)
            {
                score += bestLetterScore;
                matchedIndices.Add((int)bestLetterIdx);
            }

            outScore = score;
            return patternIdx == patternLength;
        }

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

public Boolean Equals(ReadOnlySpan<Char> other, Case casing) {
			if (Count != other.Length) { return false; }
			Int32 i = 0;
			switch (casing) {
			case Case.Insensitive:
				foreach (Char item in this) {
					if (!Char.ToUpper(item).Equals(Char.ToUpper(other[i++]))) {
						return false;
					}
				}
				break;
			case Case.Sensitive:
				foreach (Char item in this) {
					if (!item.Equals(other[i++])) {
						return false;
					}
				}
				break;
			default:
				throw new ArgumentException("Casing is not a valid Case value.", nameof(casing));
			}
			return true;
		}

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

public Boolean Equals(ReadOnlySpan<Char> other, Case casing) {
			if (Count != other.Length) { return false; }
			Int32 i = 0;
			switch (casing) {
			case Case.Insensitive:
				foreach (Char item in this) {
					if (!Char.ToUpper(item).Equals(Char.ToUpper(other[i++]))) {
						return false;
					}
				}
				break;
			case Case.Sensitive:
				foreach (Char item in this) {
					if (!item.Equals(other[i++])) {
						return false;
					}
				}
				break;
			default:
				throw new ArgumentException("Casing is not a valid Case value.", nameof(casing));
			}
			return true;
		}

19 Source : InputFrame.cs
with MIT License
from EverestAPI

public static bool TryParse(string line, int studioLine, InputFrame prevInputFrame, out InputFrame inputFrame) {
            int index = line.IndexOf(",", StringComparison.Ordinal);
            string framesStr;
            if (index == -1) {
                framesStr = line;
                index = 0;
            } else {
                framesStr = line.Substring(0, index);
            }

            if (!int.TryParse(framesStr, out int frames)) {
                inputFrame = null;
                return false;
            }

            frames = Math.Min(frames, 9999);
            inputFrame = new InputFrame {Line = studioLine, Frames = frames};
            while (index < line.Length) {
                char c = line[index];

                switch (char.ToUpper(c)) {
                    case 'L':
                        inputFrame.Actions ^= Actions.Left;
                        break;
                    case 'R':
                        inputFrame.Actions ^= Actions.Right;
                        break;
                    case 'U':
                        inputFrame.Actions ^= Actions.Up;
                        break;
                    case 'D':
                        inputFrame.Actions ^= Actions.Down;
                        break;
                    case 'J':
                        inputFrame.Actions ^= Actions.Jump;
                        break;
                    case 'X':
                        inputFrame.Actions ^= Actions.Dash;
                        break;
                    case 'G':
                        inputFrame.Actions ^= Actions.Grab;
                        break;
                    case 'S':
                        inputFrame.Actions ^= Actions.Start;
                        break;
                    case 'Q':
                        inputFrame.Actions ^= Actions.Restart;
                        break;
                    case 'N':
                        inputFrame.Actions ^= Actions.Journal;
                        break;
                    case 'K':
                        inputFrame.Actions ^= Actions.Jump2;
                        break;
                    case 'C':
                        inputFrame.Actions ^= Actions.Dash2;
                        break;
                    case 'O':
                        inputFrame.Actions ^= Actions.Confirm;
                        break;
                    case 'Z':
                        inputFrame.Actions ^= Actions.DemoDash;
                        break;
                    case 'V':
                        inputFrame.Actions ^= Actions.DemoDash2;
                        break;
                    case 'F':
                        inputFrame.Actions ^= Actions.Feather;
                        index++;
                        string angleAndUpperLimit = line.Substring(index + 1).Trim();
                        if (angleAndUpperLimit.IsNotNullOrEmpty()) {
                            string[] args = angleAndUpperLimit.Split(',');
                            string angle = args[0];
                            if (float.TryParse(angle, out float angleFloat)) {
                                inputFrame.Angle = angleFloat;
                            }

                            if (args.Length >= 2 && float.TryParse(args[1], out float upperLimitFloat)) {
                                inputFrame.UpperLimit = upperLimitFloat;
                            }
                        }

                        inputFrame.AngleVector2 = replacedogHelper.ComputeAngleVector2(inputFrame, out Vector2Short angleVector2Short);
                        inputFrame.AngleVector2Short = angleVector2Short;
                        continue;
                }

                index++;
            }

            if (prevInputFrame != null) {
                prevInputFrame.Next = inputFrame;
                inputFrame.Previous = prevInputFrame;
            }

            LibTasHelper.WriteLibTasFrame(inputFrame);

            return true;
        }

19 Source : GLParser.cs
with MIT License
from EvergineTeam

private string ComputeShortName(string enumName)
            {
                string result = string.Empty;
                string lowername = enumName.ToLower();
                var strings = lowername.Split('_');

                for (int i = 1; i < strings.Length; i++)
                {
                    string temp = strings[i];
                    result += char.ToUpper(temp[0]) + temp.Substring(1);
                }

                return result;
            }

19 Source : Language.cs
with GNU General Public License v2.0
from evgeny-nadymov

public static string CapitalizeFirstLetter(string data)
        {
            var chars = data.ToCharArray();

            // Find the Index of the first letter
            var charac = data.FirstOrDefault(char.IsLetter);
            if (charac == default(char)) return data;
            var i = data.IndexOf(charac);

            // capitalize that letter
            chars[i] = char.ToUpper(chars[i]);

            return new string(chars);
        }

19 Source : InspectorEditor.cs
with MIT License
from ExtendRealityLtd

protected virtual bool IsAttributeForProperty(
            SerializedProperty property,
            MethodInfo methodInfo,
            HandlesMemberChangeAttribute attribute)
        {
            string propertyPath = property.propertyPath;
            if (attribute.DataMemberName == propertyPath)
            {
                return true;
            }

            char firstChar = propertyPath[0];
            firstChar = char.IsLower(firstChar) ? char.ToUpper(firstChar) : char.ToLower(firstChar);
            string alternativePropertyPath = firstChar + propertyPath.Substring(1);
            if (attribute.DataMemberName != alternativePropertyPath)
            {
                return false;
            }

            Type type = methodInfo.DeclaringType;
            return type?.GetProperty(
                    alternativePropertyPath,
                    BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                != null
                && GetPrivateField(type, propertyPath)?.GetCustomAttribute<SerializeField>() != null;
        }

19 Source : NodeBindingGenerator.cs
with GNU General Public License v3.0
from F1uctus

string GeneratePropertyCode(IFieldSymbol field) {
            string propertyName = char.ToUpper(field.Name[0]) + field.Name.Substring(1);
            var isList = field.Type.Name.StartsWith("NodeList");
            string[] attributes = field.GetAttributes()
                .Where(a => !a.AttributeClreplaced!.DefaultEquals(leafSyntaxNodeAttribute))
                .Select(a => "[" + a + "]")
                .ToArray();
            string type =
                field.Type.WithNullableAnnotation(
                        isList
                            ? NullableAnnotation.NotAnnotated
                            : field.Type.NullableAnnotation
                    )
                    .ToString();
            string bindMethodName =
                field.Type.NullableAnnotation == NullableAnnotation.Annotated && !isList
                    ? "BindNullable"
                    : "Bind";
            string refFieldName =
                field.Name == "value"
                    ? "this.value"
                    : SyntaxFacts.GetKeywordKind(field.Name) == SyntaxKind.None
                   && SyntaxFacts.GetContextualKeywordKind(field.Name) == SyntaxKind.None
                        ? field.Name
                        : "@" + field.Name;
            string getPattern =
                isList
                    ? "InitIfNull(ref {0})"
                    : "{0}";
            return $@"{string.Join(nl, attributes)}
public {type} {propertyName} {{
    get => {string.Format(getPattern, refFieldName)};
    set => {refFieldName} = {bindMethodName}(value);
}}".Indent(8);
        }

19 Source : Program.cs
with MIT License
from FabianTerhorst

private static string GetAltNativeFileName(string fileName)
        {
            var newFileName = fileName.Replace(".h", ".cs").FirstCharToUpper();
            var indexOf = newFileName.IndexOf("_", StringComparison.Ordinal);
            //TODO: only works with one _ in string
            if (indexOf != -1)
            {
                var oldNoneUpperCase = newFileName[indexOf + 1];
                var upperCaseString = char.ToUpper(oldNoneUpperCase).ToString();
                newFileName = newFileName.Replace("_" + oldNoneUpperCase, upperCaseString);
            }

            return "AltV." + newFileName;
        }

19 Source : FontConverter.cs
with GNU General Public License v3.0
from faib920

private FontStyle ParseFontStyle(string flag)
        {
            var style = FontStyle.Regular;
            foreach (var c in flag)
            {
                switch (char.ToUpper(c))
                {
                    case 'B':
                        style |= FontStyle.Bold;
                        break;
                    case 'U':
                        style |= FontStyle.Underline;
                        break;
                    case 'I':
                        style |= FontStyle.Italic;
                        break;
                    case 'S':
                        style |= FontStyle.Strikeout;
                        break;
                }
            }

            return style;
        }

19 Source : PhysicalFileSystem.cs
with GNU General Public License v3.0
from FanTranslatorsInternational

protected override string ConvertPathToInternalImpl(UPath path)
        {
            var absolutePath = path.FullName;

            if (IsOnWindows)
            {
                if (!absolutePath.StartsWith(DrivePrefixOnWindows) ||
                    absolutePath.Length == DrivePrefixOnWindows.Length ||
                    !IsDriveLetter(absolutePath[DrivePrefixOnWindows.Length]))
                    throw new ArgumentException($"A path on Windows must start by `{DrivePrefixOnWindows}` followed by the drive letter");

                var driveLetter = char.ToUpper(absolutePath[DrivePrefixOnWindows.Length]);
                if (absolutePath.Length != DrivePrefixOnWindows.Length + 1 &&
                    absolutePath[DrivePrefixOnWindows.Length + 1] !=
                    UPath.DirectorySeparator)
                    throw new ArgumentException($"The driver letter `/{DrivePrefixOnWindows}{absolutePath[DrivePrefixOnWindows.Length]}` must be followed by a `/` or nothing in the path -> `{absolutePath}`");

                var builder = new StringBuilder();
                builder.Append(driveLetter).Append(":\\");
                if (absolutePath.Length > DrivePrefixOnWindows.Length + 1)
                    builder.Append(absolutePath.Replace(UPath.DirectorySeparator, '\\').Substring(DrivePrefixOnWindows.Length + 2));

                var result = builder.ToString();
                builder.Length = 0;
                return result;
            }
            return absolutePath;
        }

19 Source : JsonClassGenerator.cs
with MIT License
from FastReports

internal static string ToreplacedleCase(string str)
        {
            var sb = new StringBuilder(str.Length);
            var flag = true;

            for (int i = 0; i < str.Length; i++)
            {
                var c = str[i];
                if (char.IsLetterOrDigit(c))
                {
                    sb.Append(flag ? char.ToUpper(c) : c);
                    flag = false;
                }
                else
                {
                    flag = true;
                }
            }

            return sb.ToString();
        }

19 Source : NumToWordsBase.cs
with MIT License
from FastReports

private string Str(decimal value, WordInfo senior, WordInfo junior)
        {
            bool minus = false;
            if (value < 0)
            {
                value = -value;
                minus = true;
            }

            long n = (long)value;
            int remainder = (int)((value - n + 0.005m) * 100);
            if (remainder >= 100)
            {
                n++;
                remainder = 0;
            }

            StringBuilder r = new StringBuilder();

            Str(n, senior, r);

            if (minus)
                r.Insert(0, GetMinus() + " ");

            if (junior != null)
            {
                r.Append(GetDecimalSeparator() + remainder.ToString("00 "));
                r.Append(Case(remainder, junior));
            }

            r[0] = char.ToUpper(r[0]);
            return r.ToString();
        }

19 Source : Extensions.cs
with MIT License
from felixkmh

public static string Capitalize(this string input)
        {
            var builder = new StringBuilder();
            bool lastCharSpace = true;
            foreach (var c in input)
            {
                if (lastCharSpace)
                {
                    builder.Append(char.ToUpper(c));
                } else
                {
                    builder.Append(c);
                }
                lastCharSpace = c == ' ' || c == '\t';
            }
            return builder.ToString();
        }

19 Source : Utils.cs
with GNU General Public License v3.0
from fengberd

public static IntPtr GetCVarAddress(IntPtr hProcess,string name)
        {
            int someMagicVariable1 = 0, someMagicVariable2 = 0;
            for(int i = 0;i < name.Length;i += 2)
            {
                someMagicVariable2 = charcodeTable.table[someMagicVariable1 ^ char.ToUpper(name[i])];
                if(i + 1 == name.Length)
                {
                    break;
                }
                someMagicVariable1 = charcodeTable.table[someMagicVariable2 ^ char.ToUpper(name[i + 1])];
            }
            int hash = someMagicVariable1 | (someMagicVariable2 << 8);
            IntPtr pointer = ReadMemory<IntPtr>(hProcess,ReadMemory<IntPtr>(hProcess,cvarTable + 0x34) + ((byte)hash * 4));
            while(pointer != IntPtr.Zero)
            {
                if(ReadMemory<int>(hProcess,pointer) == hash)
                {
                    IntPtr cvarPointer = ReadMemory<IntPtr>(hProcess,pointer + 0x4);
                    if(ReadText(hProcess,ReadMemory<IntPtr>(hProcess,cvarPointer + 0xC)) == name)
                    {
                        return cvarPointer;
                    }
                }
                pointer = ReadMemory<IntPtr>(hProcess,pointer + 0xC);
            }
            return IntPtr.Zero;
        }

19 Source : OrderByExtensions.cs
with MIT License
from firebend

public static (Expression<Func<T, object>> order, bool ascending) ToOrderByGroup<T>(this string source)
        {
            if (source == null)
            {
                return default;
            }

            var spec = source.Split(':');

            var name = spec[0];

            if (string.IsNullOrWhiteSpace(name))
            {
                return default;
            }

            if (char.IsLower(name[0]))
            {
                name = $"{char.ToUpper(name[0])}{name.Substring(1)}";
            }

            var type = typeof(T);

            var propertyInfo = type.GetProperty(name);

            if (propertyInfo == null)
            {
                return default;
            }

            var arg = Expression.Parameter(type, "x");

            Expression expr = Expression.Property(arg, propertyInfo);

            if (propertyInfo.PropertyType.IsValueType)
            {
                expr = Expression.Convert(expr, typeof(object));
            }

            var expression = Expression.Lambda<Func<T, object>>(expr, arg);

            var descending = spec
                .Skip(1)
                .Take(1)
                .Where(x => !string.IsNullOrWhiteSpace(x))
                .Select(x => char.ToLower(x.First()))
                .Select(x => x == 'd' || x == 'f')
                .FirstOrDefault();

            return (expression, !descending);
        }

See More Examples