System.Collections.Generic.IEnumerable.Aggregate(string, System.Func)

Here are the examples of the csharp api System.Collections.Generic.IEnumerable.Aggregate(string, System.Func) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

541 Examples 7

19 View Source File : ConsumersHealthCheck.cs
License : MIT License
Project Creator : BEagle1984

public async Task<HealthCheckResult> CheckHealthAsync(
            HealthCheckContext context,
            CancellationToken cancellationToken = default)
        {
            Check.NotNull(context, nameof(context));

            IReadOnlyCollection<IConsumer> disconnectedConsumers =
                await _service.GetDisconnectedConsumersAsync(_minHealthyStatus, _gracePeriod, _endpointsFilter)
                    .ConfigureAwait(false);

            if (disconnectedConsumers.Count == 0)
                return new HealthCheckResult(HealthStatus.Healthy);

            string errorMessage = disconnectedConsumers.Aggregate(
                "One or more consumers are not connected:",
                (current, consumer) =>
                    $"{current}{Environment.NewLine}- " +
                    $"{consumer.Endpoint.DisplayName} " +
                    $"[{consumer.Id}]");

            return new HealthCheckResult(context.Registration.FailureStatus, errorMessage);
        }

19 View Source File : LoginServer.cs
License : GNU General Public License v3.0
Project Creator : BlowaXD

private static void PrintHeader()
        {
            Console.replacedle = "SaltyEmu - Login";
            const string text = @"
███████╗ █████╗ ██╗  ████████╗██╗   ██╗███████╗███╗   ███╗██╗   ██╗    ██╗      ██████╗  ██████╗ ██╗███╗   ██╗
██╔════╝██╔══██╗██║  ╚══██╔══╝╚██╗ ██╔╝██╔════╝████╗ ████║██║   ██║    ██║     ██╔═══██╗██╔════╝ ██║████╗  ██║
███████╗███████║██║     ██║    ╚████╔╝ █████╗  ██╔████╔██║██║   ██║    ██║     ██║   ██║██║  ███╗██║██╔██╗ ██║
╚════██║██╔══██║██║     ██║     ╚██╔╝  ██╔══╝  ██║╚██╔╝██║██║   ██║    ██║     ██║   ██║██║   ██║██║██║╚██╗██║
███████║██║  ██║███████╗██║      ██║   ███████╗██║ ╚═╝ ██║╚██████╔╝    ███████╗╚██████╔╝╚██████╔╝██║██║ ╚████║
╚══════╝╚═╝  ╚═╝╚══════╝╚═╝      ╚═╝   ╚══════╝╚═╝     ╚═╝ ╚═════╝     ╚══════╝ ╚═════╝  ╚═════╝ ╚═╝╚═╝  ╚═══╝
";
            string separator = new string('=', Console.WindowWidth);
            string logo = text.Split('\n').Select(s => string.Format("{0," + (Console.WindowWidth / 2 + s.Length / 2) + "}\n", s))
                .Aggregate("", (current, i) => current + i);
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(separator + logo + separator);
            Console.ForegroundColor = ConsoleColor.White;
        }

19 View Source File : BaseSearcher.cs
License : MIT License
Project Creator : arasplm

public List<ItemSearchResult> RunSearch(string itemType, SavedSearch search)
		{
			var itemForSearch = innovatorInstance.newItem(itemType, "get");
			foreach (var prop in search.SavedSearchProperties)
			{
				if (!string.IsNullOrEmpty(prop.PropertyValue) && !string.Equals(prop.PropertyValue, "Indeterminate"))
				{
					if (prop.DataType == PropertyDataType.Item)
					{
						itemForSearch.setProperty(prop.PropertyName, CreateItemSearchProperty(prop.DataSource, prop.PropertyValue));
					}
					else if (prop.DataType == PropertyDataType.Date)
					{
						DateTime date;
						if (DateTime.TryParse(prop.PropertyValue, out date))
						{
							string value = date.ToString("yyyy-MM-dd");

							itemForSearch.setProperty(prop.PropertyName, $"{value}T00:00:00 and {value}T23:59:59");
							itemForSearch.setPropertyAttribute(prop.PropertyName, "condition", "between");
						}
					}
					else
					{
						itemForSearch.setProperty(prop.PropertyName, prop.PropertyValue);
						if (prop.PropertyValue.Contains("*") || prop.PropertyValue.Contains("%"))
						{
							itemForSearch.setPropertyAttribute(prop.PropertyName, "condition", "like");
						}
					}
				}
			}

			itemForSearch.setAttribute("page", search.Page.ToString());
			if (!string.IsNullOrEmpty(search.PageSize))
			{
				itemForSearch.setAttribute("pagesize", search.PageSize.ToString());
			}

			var codes = new Dictionary<string, string>() { { ">", ">" }, { "<", "<" }, };

			string parsedString = itemForSearch.ToString();
			parsedString = codes.Aggregate(parsedString, (current, code) => current.Replace(code.Key, code.Value));

			itemForSearch.loadAML(parsedString);

			UpdateSearch(itemForSearch, itemType, search.SavedSearchProperties);

			itemForSearch = itemForSearch.apply();
			//itemForSearch.IsErrorItem(true);
			List<dynamic> itemForSearchList = new List<dynamic>();
			var itemsCount = itemForSearch.gereplacedemCount();
			for (int i = 0; i < itemsCount; i++)
			{
				var currenreplacedem = itemForSearch.gereplacedemByIndex(i);
				itemForSearchList.Add(currenreplacedem);

			}
			UpdateFoundedItems(itemForSearchList);
			var resultSearchList = new List<ItemSearchResult>();

			for (int i = 0; i < itemForSearchList.Count; i++)
			{
				var currenreplacedem = itemForSearchList[i];
				ItemSearchResult searchResult = new ItemSearchResult();
				foreach (var item in search.SavedSearchProperties)
				{
					var value = currenreplacedem.getProperty(item.PropertyName);
					ItemSearchPropertyInfo foundedPropertyInfo;
					if (item.PropertyName == "locked_by_id")
					{
						var lockedPropertyInfo = new LockedByPropertyInfo();
						lockedPropertyInfo.IsLocked = !string.IsNullOrEmpty(value);
						lockedPropertyInfo.IsLockedByMe = string.Equals(value, innovatorInstance.getUserID());
						lockedPropertyInfo.PropertyName = item.PropertyName;
						foundedPropertyInfo = lockedPropertyInfo;
					}
					else if (item.DataType == PropertyDataType.ColorList)
					{
						var colorProp = item as ColorListPropertyInfo;
						foundedPropertyInfo = new ColorListPropertyInfo()
						{
							PropertyName = item.PropertyName,
							PropertyValue = value,
							DataType = item.DataType,
							ColorSource = colorProp.ColorSource

						};
					}
					else if (item.DataType == PropertyDataType.Item)
					{
						var label = currenreplacedem.getPropertyAttribute(item.PropertyName, "keyed_name", string.Empty);

						foundedPropertyInfo = new ItemSearchPropertyInfo()
						{
							PropertyName = item.PropertyName,
							PropertyValue = value,
							Label = label,
							DataType = item.DataType
						};
					}
					else
					{
						foundedPropertyInfo = new ItemSearchPropertyInfo()
						{
							PropertyName = item.PropertyName,
							PropertyValue = value,
							DataType = item.DataType
						};
					}

					searchResult.FoundedItems.Add(foundedPropertyInfo);
				}

				resultSearchList.Add(searchResult);
			}

			if (resultSearchList.Count > 0)
			{
				var firsreplacedem = itemForSearch.gereplacedemByIndex(0);
				var page = firsreplacedem.getAttribute("page", "1");
				var pageMax = firsreplacedem.getAttribute("pagemax", "1");

				int value;
				search.Page = int.TryParse(page, out value) ? value : 1;
				search.PageMax = int.TryParse(pageMax, out value) ? value : 1;
			}
			else
			{
				search.Page = 1;
				search.PageMax = 1;
			}

			return resultSearchList;
		}

19 View Source File : MergeCacheEntry.cs
License : The Unlicense
Project Creator : BattletechModders

private string TextAppend(string originalContent)
        {
            return Merges.Aggregate(originalContent, (current, entry) => current + File.ReadAllText(entry.AbsolutePath));
        }

19 View Source File : TemplateProject.cs
License : MIT License
Project Creator : arcus-azure

public void AddTypeAsFile<TFixture>(IDictionary<string, string> replacements = null, params string[] namespaces)
        {
            replacements = replacements ?? new Dictionary<string, string>();
            namespaces = namespaces ?? new string[0];

            string srcPath = FindFixtureTypeInDirectory(FixtureDirectory, typeof(TFixture));
            string destPath = Path.Combine(ProjectDirectory.FullName, Path.Combine(namespaces), typeof(TFixture).Name + ".cs");
            File.Copy(srcPath, destPath);

            string key = typeof(TFixture).Namespace ?? throw new InvalidOperationException("Generic fixture requires a namespace");
            string value = namespaces.Length == 0 ? ProjectName : $"{ProjectName}.{String.Join(".", namespaces)}";
            replacements[key] = value;

            string content = File.ReadAllText(destPath);
            content = replacements.Aggregate(content, (txt, kv) => txt.Replace(kv.Key, kv.Value));
            
            File.WriteAllText(destPath, content);
        }

19 View Source File : KernelManager.cs
License : MIT License
Project Creator : andreaschiavinato

public string StartKernel(string sessionId, string kernelName)
        {
            _kernelSpec = KernelSpecs.kernelspecs[kernelName];

            var connectionFile = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                "jupyter",
                "runtime",
                sessionId + ".json");
            
            var kernelExe = _kernelSpec.spec.argv[0];
            var kernalArgs = _kernelSpec.spec.argv
                .Skip(1)
                .Aggregate(string.Empty, (a, b) => a + " " + b)
                .Replace("{connection_file}", connectionFile);
            
            _kernelProcess = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName = kernelExe,
                    Arguments = kernalArgs,
                    UseShellExecute = false,
                    RedirectStandardOutput = false,
                    RedirectStandardInput = true,
                    CreateNoWindow = true
                }
            };

            _kernelProcess.Start();
            
            WaitConnectionFileWritten(connectionFile);
            return connectionFile;
        }

19 View Source File : Downloader.cs
License : GNU General Public License v3.0
Project Creator : Bililive

private static string CleanFileName(string fileName) => Path.GetInvalidFileNameChars().Aggregate(fileName, (current, c) => current.Replace(c.ToString(), string.Empty));

19 View Source File : SpParameter.cs
License : Apache License 2.0
Project Creator : agoda-com

public static string CreateCacheKey(this SpParameter[] parameters, string spName)
        {
            if (!parameters?.Any() ?? true)
            {
                return $"{dbPrefix}{spName}";
            }

            return parameters?
                .OrderBy(x => x.Name, StringComparer.OrdinalIgnoreCase)
                .Aggregate(
                    $"{dbPrefix}{spName}:",
                    (seed, pair) =>
                    {
                        var value = pair.Value is DateTime dateTime
                            ? dateTime.Ticks.ToString()
                            : pair.Value.ToString();
                        return $"{seed}@{pair.Name}+{value}&";
                    });
        }

19 View Source File : RelationService.cs
License : GNU General Public License v3.0
Project Creator : BlowaXD

private static void PrintHeader()
        {
            Console.replacedle = "SaltyEmu - RelationService";
            const string text = @"
███████╗ █████╗ ██╗  ████████╗██╗   ██╗███████╗███╗   ███╗██╗   ██╗    ███████╗██████╗ ██╗███████╗███╗   ██╗██████╗ ███████╗
██╔════╝██╔══██╗██║  ╚══██╔══╝╚██╗ ██╔╝██╔════╝████╗ ████║██║   ██║    ██╔════╝██╔══██╗██║██╔════╝████╗  ██║██╔══██╗██╔════╝
███████╗███████║██║     ██║    ╚████╔╝ █████╗  ██╔████╔██║██║   ██║    █████╗  ██████╔╝██║█████╗  ██╔██╗ ██║██║  ██║███████╗
╚════██║██╔══██║██║     ██║     ╚██╔╝  ██╔══╝  ██║╚██╔╝██║██║   ██║    ██╔══╝  ██╔══██╗██║██╔══╝  ██║╚██╗██║██║  ██║╚════██║
███████║██║  ██║███████╗██║      ██║   ███████╗██║ ╚═╝ ██║╚██████╔╝    ██║     ██║  ██║██║███████╗██║ ╚████║██████╔╝███████║
╚══════╝╚═╝  ╚═╝╚══════╝╚═╝      ╚═╝   ╚══════╝╚═╝     ╚═╝ ╚═════╝     ╚═╝     ╚═╝  ╚═╝╚═╝╚══════╝╚═╝  ╚═══╝╚═════╝ ╚══════╝
";
            Console.WindowWidth = text.Split('\n')[1].Length + (((text.Split('\n')[1].Length % 2) == 0) ? 1 : 2);
            string separator = new string('=', Console.WindowWidth);
            string logo = text.Split('\n').Select(s => string.Format("{0," + (Console.WindowWidth / 2 + separator.Length / 2) + "}\n", s))
                .Aggregate("", (current, i) => current + i);
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(separator + logo + separator);
            Console.ForegroundColor = ConsoleColor.White;
        }

19 View Source File : StringExtensions.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn

public static string AsFileName(this string input, bool throwExceptionOnInvalidCharacters = true)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return input;
            }

            char[] illegalFileNameCharacters = System.IO.Path.GetInvalidFileNameChars();
            if (throwExceptionOnInvalidCharacters)
            {
                if (illegalFileNameCharacters.Any(ic => input.Any(i => ic == i)))
                {
                    throw new ArgumentOutOfRangeException(nameof(input));
                }

                return input;
            }

            return illegalFileNameCharacters.Aggregate(input, (current, c) => current.Replace(c, '_'));
        }

19 View Source File : Game.Information.cs
License : GNU General Public License v3.0
Project Creator : BardMusicPlayer

private string GetGamePath()
        {
            try
            {
                var gamePath = Process.Modules.Cast<ProcessModule>()
                    .Aggregate("",
                        (current, module) =>
                            module.ModuleName.ToLower() switch
                            {
                                "ffxiv_dx11.exe" => Directory
                                    .GetParent(Path.GetDirectoryName(module.FileName) ?? string.Empty)
                                    ?.FullName,
                                _ => current
                            }
                    );

                if (string.IsNullOrEmpty(gamePath))
                    throw new BmpSeerGamePathException(
                        "Cannot locate the running directory of this game's ffxiv_dx11.exe");

                return gamePath + @"\";
            }

19 View Source File : ApiControllerBase.cs
License : MIT License
Project Creator : armanab

protected HttpResponseMessage RedirectToUrl(string redirectUrl, string p1 = null)
        {
            var url = redirectUrl;
            var parameters = new[] { p1 };

            url = parameters.Where(param => !string.IsNullOrEmpty(param)).Aggregate(url, (current, param) => current + (";" + param.Replace("/", "")));

            var pageHtml = @"<html><head><meta charset = 'utf-8'><replacedle>درحال انتقال ...</replacedle></head><body><script>window.location.replace('" + url + "')</script></body></html>";
            return new HttpResponseMessage
            {
                Content = new StringContent(pageHtml, Encoding.UTF8, "text/html") { }
            };
        }

19 View Source File : StringExtensions.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn

public static string AsFileName(this string input, bool throwExceptionOnInvalidCharacters = true)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return input;
            }

            char[] illegalFileNameCharacters = System.IO.Path.GetInvalidFileNameChars();
            if (throwExceptionOnInvalidCharacters)
            {
                if (illegalFileNameCharacters.Any(ic => input.Any(i => ic == i)))
                {
                    throw new ArgumentOutOfRangeException(nameof(input));
                }

                if (input == "..")
                {
                    throw new ArgumentOutOfRangeException(nameof(input));
                }

                return input;
            }

            if (input == "..")
            {
               return "-";
            }

            return illegalFileNameCharacters.Aggregate(input, (current, c) => current.Replace(c, '-'));
        }

19 View Source File : PercentEncodeReplace.cs
License : MIT License
Project Creator : bbartels

public static string Replace(string url)
        {
            if (url == null) { return null; }

            return percentEncodeMaps.Aggregate(url, (current, map) 
                                => current.Replace(map.Key, map.Value));
        }

19 View Source File : ViewMethods.cs
License : MIT License
Project Creator : AElfProject

public override MinerReplacementInformation GetMinerReplacementInformation(
            GetMinerReplacementInformationInput input)
        {
            var evilMinersPubKeys = GetEvilMinersPubkeys(input.CurrentMinerList);
            Context.LogDebug(() => $"Got {evilMinersPubKeys.Count} evil miners pubkeys from {input.CurrentMinerList}");
            var alternativeCandidates = new List<string>();
            var latestSnapshot = GetPreviousTermSnapshotWithNewestPubkey();
            // Check out election snapshot.
            if (latestSnapshot != null && latestSnapshot.ElectionResult.Any())
            {
                Context.LogDebug(() => $"Previous term snapshot:\n{latestSnapshot}");
                var maybeNextCandidates = latestSnapshot.ElectionResult
                    // Except initial miners.
                    .Where(cs =>
                        !State.InitialMiners.Value.Value.Contains(
                            ByteString.CopyFrom(ByteArrayHelper.HexStringToByteArray(cs.Key))))
                    // Except current miners.
                    .Where(cs => !input.CurrentMinerList.Contains(cs.Key))
                    .OrderByDescending(s => s.Value).ToList();
                var take = Math.Min(evilMinersPubKeys.Count, maybeNextCandidates.Count);
                alternativeCandidates.AddRange(maybeNextCandidates.Select(c => c.Key).Take(take));
                Context.LogDebug(() =>
                    $"Found alternative miner from candidate list: {alternativeCandidates.Aggregate("\n", (key1, key2) => key1 + "\n" + key2)}");
            }

            // If the count of evil miners is greater than alternative candidates, add some initial miners to alternative candidates.
            var diff = evilMinersPubKeys.Count - alternativeCandidates.Count;
            if (diff > 0)
            {
                var takeAmount = Math.Min(diff, State.InitialMiners.Value.Value.Count);
                var selectedInitialMiners = State.InitialMiners.Value.Value
                    .Select(k => k.ToHex())
                    .Where(k => !State.BannedPubkeyMap[k])
                    .Where(k => !input.CurrentMinerList.Contains(k)).Take(takeAmount);
                alternativeCandidates.AddRange(selectedInitialMiners);
            }

            return new MinerReplacementInformation
            {
                EvilMinerPubkeys = {evilMinersPubKeys},
                AlternativeCandidatePubkeys = {alternativeCandidates}
            };
        }

19 View Source File : Extensions.cs
License : MIT License
Project Creator : BepInEx

public static string Join<T>(this IEnumerable<T> enumeration, Func<T, string> converter = null, string delimiter = ", ")
		{
			if (converter is null) converter = t => t.ToString();
			return enumeration.Aggregate("", (prev, curr) => prev + (prev.Length > 0 ? delimiter : "") + converter(curr));
		}

19 View Source File : KTest.cs
License : GNU General Public License v3.0
Project Creator : AntoineCrb

private static void Main()
        {
            // Test Values
            short rep = 1;
            short width = 5, height = 5;
            Position start = new Position(0, 0), end = new Position(4, 4);
            var grid = new byte[]
            {
                0, 0, 0, 0, 0,
                0, 0, 0, 0, 0,
                0, 0, 0, 0, 0,
                0, 0, 0, 0, 0,
                0, 0, 0, 0, 0,
            };
            //

            DateTime t = DateTime.Now;
            Position[] path = null;
            for (int a = 0; a < rep; a++)
            {
                path = KPathfinder.Algorithms.AStar.FindPath(start, end, new Map(width, height, grid));
            }

            Console.Write($"Time used for {rep} repereplacedions : {DateTime.Now - t}\n" + (path == null
                              ? "Impossible Path"
                              : "Path:\n" + path.Aggregate("", (a, b) => a + $"x: {b.X}, y: {b.Y}\n")));
        }

19 View Source File : ArrayPropAssignmentBehavior.cs
License : MIT License
Project Creator : bleroy

[Test]
        public void SingleArrayArgumentBecomesDynamic() {
            dynamic alpha = new Clay(new PropBehavior(), new ArrayPropreplacedignmentBehavior());

            alpha
                .Names(new[] { "foo", "bar", "quad" })
                .Places(new int[0]);

            alpha.Names.Add("quux");
            alpha.Places.Add(4, 5, 6);

            IEnumerable<string> names = alpha.Names;
            IEnumerable<int> places = alpha.Places;

            replacedert.That(names.Count(), Is.EqualTo(4));
            replacedert.That(names.Aggregate("|", (a, b) => a + b + "|"), Is.EqualTo("|foo|bar|quad|quux|"));
            replacedert.That(places.Count(), Is.EqualTo(3));
            replacedert.That(places.Aggregate("|", (a, b) => a + b + "|"), Is.EqualTo("|4|5|6|"));
        }

19 View Source File : MailController.cs
License : Apache License 2.0
Project Creator : AantCoder

private static void DropToWorldObject(WorldObject place, List<ThingEntry> things, string from)
        {
            var text = string.Format("OCity_UpdateWorld_TradeDetails".Translate()
                    , from
                    , place.LabelCap
                    , things.Aggregate("", (r, i) => r + Environment.NewLine + i.Name + " x" + i.Count));
            /*
            GlobalTargetInfo ti = new GlobalTargetInfo(place);
            if (place is Settlement && ((Settlement)place).Map != null)
            {
                var cell = GameUtils.GetTradeCell(((Settlement)place).Map);
                ti = new GlobalTargetInfo(cell, ((Settlement)place).Map);
            }
            */
            Find.TickManager.Pause();
            GameUtils.ShowDialodOKCancel("OCity_UpdateWorld_Trade".Translate()
                , text
                , () => DropToWorldObjectDo(place, things, from, text)
                , () => Log.Message("Drop Mail from " + from + ": " + text)
            );
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : BlowaXD

private static void PrintHeader()
        {
            Console.replacedle = "SaltyEmu - Family";
            const string text = @"
███████╗ █████╗ ██╗  ████████╗██╗   ██╗███████╗███╗   ███╗██╗   ██╗   ███████╗ █████╗ ███╗   ███╗██╗██╗  ██╗   ██╗
██╔════╝██╔══██╗██║  ╚══██╔══╝╚██╗ ██╔╝██╔════╝████╗ ████║██║   ██║   ██╔════╝██╔══██╗████╗ ████║██║██║  ╚██╗ ██╔╝
███████╗███████║██║     ██║    ╚████╔╝ █████╗  ██╔████╔██║██║   ██║   █████╗  ███████║██╔████╔██║██║██║   ╚████╔╝ 
╚════██║██╔══██║██║     ██║     ╚██╔╝  ██╔══╝  ██║╚██╔╝██║██║   ██║   ██╔══╝  ██╔══██║██║╚██╔╝██║██║██║    ╚██╔╝  
███████║██║  ██║███████╗██║      ██║   ███████╗██║ ╚═╝ ██║╚██████╔╝██╗██║     ██║  ██║██║ ╚═╝ ██║██║███████╗██║   
╚══════╝╚═╝  ╚═╝╚══════╝╚═╝      ╚═╝   ╚══════╝╚═╝     ╚═╝ ╚═════╝ ╚═╝╚═╝     ╚═╝  ╚═╝╚═╝     ╚═╝╚═╝╚══════╝╚═╝   
";
            Console.WindowWidth = Console.WindowWidth < text.Split('\n')[1].Length ? text.Split('\n')[1].Length : Console.WindowWidth;
            string separator = new string('=', Console.WindowWidth);
            string logo = text.Split('\n').Select(s => string.Format("{0," + (Console.WindowWidth / 2 + s.Length / 2) + "}\n", s))
                .Aggregate("", (current, i) => current + i);
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(separator + logo + separator);
            Console.ForegroundColor = ConsoleColor.White;
        }

19 View Source File : BaseRepository.cs
License : MIT License
Project Creator : ArchitectNow

protected virtual string BuildCacheKey(string methodName, params object[] parameters)
        {
            var key = $"{BuildCacheKeyPrefix()}.{methodName}";

            if (parameters != null && parameters.Length > 0)
                key = parameters.Aggregate(key, (current, param) => current + (".-" + param));

            return key;
        }

19 View Source File : Shell.cs
License : MIT License
Project Creator : Archomeda

internal static void WriteLine(string format, params object[] args)
        {
            if (SupportAnsiColors)
                format = AnsiColors.Aggregate($"{format}{{reset}}", (result, kvp) => result.Replace(kvp.Key, kvp.Value));
            else
                format = AnsiColors.Aggregate(format, (result, kvp) => result.Replace(kvp.Key, ""));

            lock (consoleLock)
            {
                if (readingInput)
                {
                    var backspaces = new string('\b', inputBuffer.Length + 1);
                    var wipe = new string(' ', inputBuffer.Length + 1);
                    SConsole.Write(backspaces);
                    SConsole.Write(wipe);
                    SConsole.Write(backspaces);
                }
                SConsole.WriteLine(format, args);
                if (readingInput)
                    SConsole.Write($">{inputBuffer}");
            }
        }

19 View Source File : PowerBIPartConverters.cs
License : MIT License
Project Creator : action-bi-toolkit

public static string ConvertToValidModelName(string name)
        { 
            const string
                forbiddenCharacters =
                    @". , ; ' ` : / \ * | ? "" & % $ ! + = ( ) [ ] { } < >"; // grabbed these from an AMO exception message
            var modelName = forbiddenCharacters // TODO Could also use TOM.Server.Databases.CreateNewName()
                .Replace(" ", "")
                .ToCharArray()
                .Aggregate(
                    name,
                    (n, c) => n.Replace(c, '_')
                );
            return modelName;
        }

19 View Source File : ConsoleWrapper.cs
License : GNU Affero General Public License v3.0
Project Creator : arklumpus

public static string Unformat(this IEnumerable<ConsoleTextSpan> formattedText)
        {
            return formattedText.Aggregate("", (a, b) => a + b.ToString());
        }

19 View Source File : StringExtensions.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn

public static string AsFileName(this string input, bool throwExceptionOnInvalidCharacters = true)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return input;
            }

            char[] illegalFileNameCharacters = System.IO.Path.GetInvalidFileNameChars();
            if (throwExceptionOnInvalidCharacters)
            {
                if (illegalFileNameCharacters.Any(ic => input.Any(i => ic == i)))
                {                    
                    throw new ArgumentOutOfRangeException(nameof(input));
                }

                return input;
            }

            return illegalFileNameCharacters.Aggregate(input, (current, c) => current.Replace(c, '-'));
        }

19 View Source File : StringExt.cs
License : MIT License
Project Creator : 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 View Source File : GrooveClient.cs
License : Apache License 2.0
Project Creator : artemshuba

private async Task<ContentResponse> LookupApiAsync(
            IEnumerable<string> itemIds,
            ContentSource? source = null,
            string language = null,
            string country = null,
            ExtraDetails extras = ExtraDetails.None,
            string continuationToken = null)
        {
            Dictionary<string, string> requestParameters = FormatRequestParameters(continuationToken, language, country, source);

            if (extras != ExtraDetails.None)
            {
                string extra = extras.ToString().Replace(", ", "+");
                requestParameters.Add("extras", extra);
            }

            string ids = itemIds.Aggregate("",
                (current, id) =>
                    current + (!string.IsNullOrEmpty(current) ? "+" : "") + id);

            if (_userTokenManager?.UserIsSignedIn == true)
            {
                return await ApiCallWithUserAuthorizationHeaderRefreshAsync(
                    headers => GetAsync<ContentResponse>(
                        Hostname,
                        $"/1/content/{ids}/lookup",
                        new CancellationToken(false),
                        requestParameters,
                        headers));
            }
            else
            {
                Dictionary<string, string> requestHeaders = await FormatRequestHeadersAsync(null);
                return await GetAsync<ContentResponse>(
                    Hostname,
                    $"/1/content/{ids}/lookup",
                    new CancellationToken(false),
                    requestParameters,
                    requestHeaders);
            }
        }

19 View Source File : StringExtensions.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn

public static string AsFileName(this string input, bool throwExceptionOnInvalidCharacters = true)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return input;
            }

            char[] illegalFileNameCharacters = Path.GetInvalidFileNameChars();
            if (throwExceptionOnInvalidCharacters)
            {
                if (illegalFileNameCharacters.Any(ic => input.Any(i => ic == i)))
                {
                    throw new ArgumentOutOfRangeException(nameof(input));
                }

                return input;
            }

            return illegalFileNameCharacters.Aggregate(input, (current, c) => current.Replace(c, '_'));
        }

19 View Source File : Game.Information.cs
License : GNU General Public License v3.0
Project Creator : BardMusicPlayer

private string GetConfigPath()
        {
            var partialConfigPath = GameRegion == GameRegion.Korea
                ? @"My Games\FINAL FANTASY XIV - KOREA\"
                : @"My Games\FINAL FANTASY XIV - A Realm Reborn\";
            var configPath = "";

            try
            {
                if (EnvironmentType == EnvironmentType.Sandboxie)
                {
                    // Per sandboxie doreplacedentation, the configuration file can be in multiple locations.
                    var sandboxieConfigFilePath = "";

                    try
                    {
                        if (File.Exists(
                            Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\Sandboxie.ini"))
                            sandboxieConfigFilePath = Environment.GetFolderPath(Environment.SpecialFolder.Windows) +
                                                      @"\Sandboxie.ini";
                        else
                            sandboxieConfigFilePath = Process.GetProcesses()
                                .Where(process => process.ProcessName.ToLower().Equals("sbiectrl"))
                                .Select(sandboxieProcess => sandboxieProcess.Modules)
                                .Aggregate(sandboxieConfigFilePath, (current1, sandboxieModules) => sandboxieModules
                                    .Cast<ProcessModule>()
                                    .Aggregate(current1, (current, sandboxieModule) =>
                                        sandboxieModule.ModuleName.ToLower() switch
                                        {
                                            "sbiectrl.exe" => Path.GetDirectoryName(sandboxieModule.FileName) +
                                                              @"\Sandboxie.ini",
                                            _ => current
                                        }));
                    }
                    finally
                    {
                        if (string.IsNullOrEmpty(sandboxieConfigFilePath))
                            throw new BmpSeerConfigPathException(
                                "This game is running in Sandboxie, however the Sandboxie.ini configuration file could not be found.");
                    }

                    // We only accept sandbox windows with the sandbox in the replacedle like " [#] [bard1] FINAL FANTASY XIV [#] ", this will fail otherwise.
                    var boxName = Process.MainWindowreplacedle.Split('[')[2].Split(']')[0]; 

                    // Note: sandboxie is a legacy program and writes it's config file in 2-byte per character mode, or Unicode in c# terms.
                    // There is a newer open source fork that may change this, we may have to deal with it later.
                    var boxRoot = File.ReadLines(sandboxieConfigFilePath, Encoding.Unicode)
                        .First(line => line.StartsWith("BoxRootFolder"))
                        .Split('=').Last() + @"\Sandbox\" + boxName + @"\";

                    if (Directory.Exists(boxRoot))
                    {
                        if (GameRegion == GameRegion.China)
                            configPath = boxRoot + GamePath.Substring(0, 1) + @"\" +
                                         GamePath.Substring(2, GamePath.Length) + @"game\" + partialConfigPath;
                        else configPath = boxRoot + @"user\current\Doreplacedents\" + partialConfigPath;
                    }
                    else
                    {
                        throw new BmpSeerConfigPathException(
                            "This game is running in Sandboxie, however the sandbox could not be found.");
                    }
                }

19 View Source File : Extensions.cs
License : MIT License
Project Creator : Adyen

public static string ObjectListToString<T>(this List<T> itemlist)
        {
            if (itemlist != null && itemlist.Any())
            {
               return itemlist.Aggregate("\n\t{ ", (current, item) => current + " " + item.ToString() + "\n") + " }";
            }
            return "";
        }

19 View Source File : CSharpUtils.cs
License : The Unlicense
Project Creator : BattletechModders

internal static string AsTextList(this IEnumerable<string> items, string prefix = "\n - ")
        {
            return items?.Aggregate("", (current, item) => current + (prefix + item));
        }

19 View Source File : Utils.cs
License : MIT License
Project Creator : AmazingDM

public static string SHA256CheckSum(string filePath)
        {
            try
            {
                var sha256 = SHA256.Create();
                var fileStream = File.OpenRead(filePath);
                return sha256.ComputeHash(fileStream).Aggregate(string.Empty, (current, b) => current + b.ToString("x2"));
            }
            catch
            {
                return "";
            }
        }

19 View Source File : Extensions.cs
License : MIT License
Project Creator : bcssov

public static string GenerateValidFileName(this string value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                return value;
            }
            var fileName = GetInvalidFileNameChars().Aggregate(value, (current, character) => current.Replace(character.ToString(), string.Empty));
            fileName = emptyStringCharacters.Aggregate(fileName, (a, b) => a.Replace(b, "_"));
            return fileName;
        }

19 View Source File : ModelMailTrade.cs
License : Apache License 2.0
Project Creator : AantCoder

public string ContentString()
        {
            return Things == null ? "" : Things.Aggregate("", (r, i) => r + Environment.NewLine + i.Name + " x" + i.Count);
        }

19 View Source File : StringExtensions.cs
License : GNU Lesser General Public License v3.0
Project Creator : BepInEx

public static string Format(this string fmt, Dictionary<string, Func<string>> vars)
        {
            return vars.Aggregate(fmt, (str, kv) => str.Replace($"{{{kv.Key}}}", kv.Value()));
        }

19 View Source File : FunctionCall.cs
License : MIT License
Project Creator : ansel86castro

public override string ToString()
        {
            return $"{Name}({Parameters.Aggregate("", (x, y) => x.ToString() + ", " + y.ToString())})";
        }

19 View Source File : Extensions.cs
License : GNU General Public License v3.0
Project Creator : BepInEx

public static string Join<T>(this IEnumerable<T> enumeration, Func<T, string> converter = null, string delimiter = ", ")
		{
			if (converter == null) converter = t => t.ToString();
			return enumeration.Aggregate("", (prev, curr) => prev + (prev != "" ? delimiter : "") + converter(curr));
		}

19 View Source File : AEDPoSContract_ViewMethods.cs
License : MIT License
Project Creator : AElfProject

private static Hash GetMinerListHash(IEnumerable<string> minerList)
        {
            return HashHelper.ComputeFrom(
                minerList.OrderBy(p => p).Aggregate("", (current, publicKey) => current + publicKey));
        }

19 View Source File : ArrayBehaviorTests.cs
License : MIT License
Project Creator : bleroy

[Test]
        public void ArrayCombinesWithOtherBehaviors() {
            dynamic combo = new Clay(
                new InterfaceProxyBehavior(),
                new PropBehavior(),
                new ArrayBehavior(),
                new NilResultBehavior());

            replacedert.That(combo.Count, Is.EqualTo(0));

            combo.Hello = "world";
            replacedert.That(combo.Hello, Is.EqualTo("world"));
            replacedert.That(combo.Hello(), Is.EqualTo("world"));
            replacedert.That(combo["Hello"], Is.EqualTo("world"));

            replacedert.That(combo.Count, Is.EqualTo(0));

            combo.Add("alpha", "beta");
            replacedert.That(combo.Count, Is.EqualTo(2));
            replacedert.That(combo[0], Is.EqualTo("alpha"));
            replacedert.That(combo[1], Is.EqualTo("beta"));

            var c2 = (ICombo)combo;
            replacedert.That(c2.Hello, Is.EqualTo("world"));
            replacedert.That(c2.Length, Is.EqualTo(2));
            replacedert.That(c2.Count, Is.EqualTo(2));
            replacedert.That(c2[0], Is.EqualTo("alpha"));
            replacedert.That(c2[1], Is.EqualTo("beta"));
            replacedert.That(c2.Again, Is.Null);

            replacedert.That(c2.Extra.replacedle, Is.Null);
            replacedert.That(c2.Extra.Description, Is.Null);

            replacedert.That(c2.Aggregate(">", (a, b) => a + "(" + b + ")"), Is.EqualTo(">(alpha)(beta)"));
        }

19 View Source File : FileUtils.cs
License : MIT License
Project Creator : AntonyCorbett

public static string CleanFileName(string filename)
        {
            return Path.GetInvalidFileNameChars().Aggregate(filename, (current, c) =>
                current.Replace(c.ToString(CultureInfo.InvariantCulture), string.Empty));
        }

19 View Source File : ArrayPropAssignmentBehavior.cs
License : MIT License
Project Creator : bleroy

[Test]
        public void InvokeMemberWithSeveralArgumentsImpliesArrayInitialization() {
            dynamic alpha = new Clay(new PropBehavior(), new ArrayPropreplacedignmentBehavior());

            alpha
                .Names("foo", "bar", "quad")
                .Places(4, 5, 6);

            alpha.Names.Add("quux");

            IEnumerable<string> names = alpha.Names;
            IEnumerable<int> places = alpha.Places;

            replacedert.That(names.Count(), Is.EqualTo(4));
            replacedert.That(names.Aggregate("|", (a, b) => a + b + "|"), Is.EqualTo("|foo|bar|quad|quux|"));
            replacedert.That(places.Count(), Is.EqualTo(3));
            replacedert.That(places.Aggregate("|", (a, b) => a + b + "|"), Is.EqualTo("|4|5|6|"));
        }

19 View Source File : ConsoleProgressBar.cs
License : MIT License
Project Creator : a-luna

private string GetProgressBarText(double currentProgress)
        {
            const string singleSpace = " ";

            var numBlocksCompleted = (int) (currentProgress * NumberOfBlocks);

            var completedBlocks =
                Enumerable.Range(0, numBlocksCompleted).Aggregate(
                    string.Empty,
                    (current, _) => current + CompletedBlock);

            var incompleteBlocks =
                Enumerable.Range(0, NumberOfBlocks - numBlocksCompleted).Aggregate(
                    string.Empty,
                    (current, _) => current + IncompleteBlock);

            var progressBar = $"{StartBracket}{completedBlocks}{incompleteBlocks}{EndBracket}";
            var percent = $"{currentProgress:P0}".PadLeft(4, '\u00a0');
            var animationFrame = AnimationSequence[AnimationIndex++ % AnimationSequence.Length];
            var animation = $"{animationFrame}";

            progressBar = DisplayBar
                ? progressBar + singleSpace
                : string.Empty;

            percent = DisplayPercentComplete
                ? percent + singleSpace
                : string.Empty;

            if (!DisplayAnimation || currentProgress is 1)
            {
                animation = string.Empty;
            }

            return (progressBar + percent + animation).TrimEnd();
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : BlowaXD

private static void PrintHeader()
        {
            Console.replacedle = "SaltyEmu - CharacterSkillService";
            const string text = @"
███████╗ █████╗ ██╗  ████████╗██╗   ██╗███████╗███╗   ███╗██╗   ██╗
██╔════╝██╔══██╗██║  ╚══██╔══╝╚██╗ ██╔╝██╔════╝████╗ ████║██║   ██║
███████╗███████║██║     ██║    ╚████╔╝ █████╗  ██╔████╔██║██║   ██║
╚════██║██╔══██║██║     ██║     ╚██╔╝  ██╔══╝  ██║╚██╔╝██║██║   ██║
███████║██║  ██║███████╗██║      ██║   ███████╗██║ ╚═╝ ██║╚██████╔╝
╚══════╝╚═╝  ╚═╝╚══════╝╚═╝      ╚═╝   ╚══════╝╚═╝     ╚═╝ ╚═════╝ 
";
            Console.WindowWidth = text.Split('\n')[1].Length + (((text.Split('\n')[1].Length % 2) == 0) ? 1 : 2);
            string separator = new string('=', Console.WindowWidth);
            string logo = text.Split('\n').Select(s => string.Format("{0," + (Console.WindowWidth / 2 + separator.Length / 2) + "}\n", s))
                .Aggregate("", (current, i) => current + i);
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(separator + logo + separator);
            Console.ForegroundColor = ConsoleColor.White;
        }

19 View Source File : NTRAPIFramework.cs
License : MIT License
Project Creator : architdate

private static string ByteToHex(byte[] datBuf) => datBuf.Aggregate("", (current, b) => current + (b.ToString("X2") + " "));

19 View Source File : DependenciesHunter.cs
License : MIT License
Project Creator : AlexeyPerov

private void OnPatternsGUI()
        {
            EnsurePatternsLoaded();
            
            _ignorePatternsFoldout = EditorGUILayout.Foldout(_ignorePatternsFoldout,
                $"Patterns Ignored in Output: {_ignoreInOutputPatterns.Count}");

            if (!_ignorePatternsFoldout) return;

            var isDirty = false;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Format: RegExp patterns");
            if (GUILayout.Button("Set Default", GUILayout.Width(300f)))
            {
                _ignoreInOutputPatterns = _defaultIgnorePatterns.ToList();
                isDirty = true;
            }

            if (GUILayout.Button("Save to Clipboard"))
            {
                var contents = _ignoreInOutputPatterns.Aggregate("Patterns:", 
                    (current, t) => current + "\n" + t);

                EditorGUIUtility.systemCopyBuffer = contents;
            }
            
            EditorGUILayout.EndHorizontal();

            var newCount = Mathf.Max(0, EditorGUILayout.IntField("Count:", _ignoreInOutputPatterns.Count));

            if (newCount != _ignoreInOutputPatterns.Count)
            {
                isDirty = true;
            }

            while (newCount < _ignoreInOutputPatterns.Count)
            {
                _ignoreInOutputPatterns.RemoveAt(_ignoreInOutputPatterns.Count - 1);
            }

            if (newCount > _ignoreInOutputPatterns.Count)
            {
                for (var i = _ignoreInOutputPatterns.Count; i < newCount; i++)
                {
                    _ignoreInOutputPatterns.Add(EditorPrefs.GetString($"{PATTERNS_PREFS_KEY}_{i}"));
                }
            }

            for (var i = 0; i < _ignoreInOutputPatterns.Count; i++)
            {
                var newValue = EditorGUILayout.TextField(_ignoreInOutputPatterns[i]);
                if (_ignoreInOutputPatterns[i] != newValue)
                {
                    isDirty = true;
                    _ignoreInOutputPatterns[i] = newValue;
                }
            }

            if (isDirty)
            {
                SavePatterns();
            }
        }

19 View Source File : StringExtension.cs
License : GNU Lesser General Public License v3.0
Project Creator : 8720826

public static string JoinString(this IEnumerable<string> values, string split)
        {
            var result = values.Aggregate(string.Empty, (current, value) => current + (split + value));
            result = result.TrimStart(split.ToCharArray());
            return result;
        }

19 View Source File : ModelMailTrade.cs
License : Apache License 2.0
Project Creator : AantCoder

public override string ContentString()
        {
            return Things == null ? "" : Things.Aggregate("", (r, i) => r + Environment.NewLine + i.Name + " x" + i.Count);
        }

19 View Source File : SyntaxWalkerBase.cs
License : MIT License
Project Creator : adrianoc

private static string ModifiersToCecil(IEnumerable<SyntaxToken> modifiers, Func<SyntaxToken, string> map)
        {
            var cecilModifierStr = modifiers.Aggregate("", (acc, token) =>
                acc + ModifiersSeparator + map(token));

            if (cecilModifierStr.Length > 0)
            {
                cecilModifierStr = cecilModifierStr.Substring(ModifiersSeparator.Length);
            }

            return cecilModifierStr;
        }

19 View Source File : StringExtensions.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn

public static string AsFileName(this string input, bool throwExceptionOnInvalidCharacters = true)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return input;
            }

            char[] illegalFileNameCharacters = Path.GetInvalidFileNameChars();
            if (throwExceptionOnInvalidCharacters)
            {
                if (illegalFileNameCharacters.Any(ic => input.Any(i => ic == i)))
                {
                    throw new ArgumentOutOfRangeException(nameof(input));
                }

                if (input == "..")
                {
                    throw new ArgumentOutOfRangeException(nameof(input));
                }

                return input;
            }

            if (input == "..")
            {
               return "-";
            }

            return illegalFileNameCharacters.Aggregate(input, (current, c) => current.Replace(c, '-'));
        }

19 View Source File : SimpleServiceClient.cs
License : Apache License 2.0
Project Creator : artemshuba

private static Uri BuildUri(
            Uri hostname, 
            string relativeUri, 
            IEnumerable<KeyValuePair<string, string>> requestParameters)
        {
            string relUri = requestParameters == null
                ? relativeUri
                : requestParameters.Aggregate(relativeUri,
                    (current, param) => current + (current.Contains("?") ? "&" : "?") + param.Key + "=" + param.Value);

            return new Uri(hostname, relUri);
        }

See More Examples