Here are the examples of the csharp api System.Linq.Enumerable.Repeat(string, int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
511 Examples
19
View Source File : BuildUtils.cs
License : MIT License
Project Creator : 1ZouLTReX1
License : MIT License
Project Creator : 1ZouLTReX1
public static void OpenProjectFolder(int goBack)
{
var back = string.Concat(Enumerable.Repeat("/..", goBack));
var process = new System.Diagnostics.Process();
process.StartInfo.FileName = Application.dataPath + back + "/";
process.StartInfo.WorkingDirectory = Application.dataPath + back + "/";
process.Start();
}
19
View Source File : ValuesController.cs
License : MIT License
Project Creator : 42skillz
License : MIT License
Project Creator : 42skillz
private static string RandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : Loops.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
[Fact]
public void ShouldIterateEnumerable()
{
ParameterExpression output = Expression.Parameter(typeof(List<string>), "output");
ParameterExpression item = Expression.Variable(typeof(string), "item");
ConstantExpression items = Expression.Constant(Enumerable.Repeat("hello world", 10));
List<string> addedItems = new List<string>();
ForEachExpression loop = X.ForEach(item, items,
Expression.Call(output, nameof(List<string>.Add), null, item)
);
Expression
.Lambda<Action<List<string>>>(loop, output)
.Compile()(addedItems);
addedItems.Count.ShouldBe(10);
addedItems[0].ShouldBe("hello world");
}
19
View Source File : TestAmf0Writer.cs
License : MIT License
Project Creator : a1q123456
License : MIT License
Project Creator : a1q123456
[TestMethod]
public void TestLongString()
{
var writer = new Amf0Writer();
var reader = new Amf0Reader();
using (var sc = new SerializationContext())
{
for (int i = 0; i < 1000; i++)
{
var val = string.Concat(Enumerable.Repeat(Guid.NewGuid().ToString(), 2000));
writer.WriteBytes(val, sc);
var buffer = new byte[sc.MessageLength];
sc.GetMessage(buffer);
reader.TryGetLongString(buffer, out var readValue, out var consumed);
replacedert.AreEqual(val, readValue);
replacedert.AreEqual(buffer.Length, consumed);
}
}
}
19
View Source File : TestAmf0Reader.cs
License : MIT License
Project Creator : a1q123456
License : MIT License
Project Creator : a1q123456
[TestMethod]
public void TestReadLongString()
{
var reader = new Amf0Reader();
using (var f = new FileStream("../../../../samples/amf0/misc/longstring.amf0", FileMode.Open))
{
var data = new byte[f.Length];
f.Read(data);
replacedert.IsTrue(reader.TryGetLongString(data, out var dataRead, out var consumed));
replacedert.AreEqual(string.Concat(Enumerable.Repeat("abc", 32767)), dataRead);
replacedert.AreEqual(consumed, f.Length);
}
}
19
View Source File : Print.cs
License : MIT License
Project Creator : Accelerider
License : MIT License
Project Creator : Accelerider
private static void WriteToConsole(string message, OutType outType = OutType.Info)
{
var backupBackground = Console.BackgroundColor;
var backupForeground = Console.ForegroundColor;
Console.BackgroundColor = OutColors[outType];
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write($"[{outType.ToString().ToUpper()}]");
Console.BackgroundColor = backupBackground;
Console.ForegroundColor = OutColors[outType];
var spaces = Enumerable.Repeat(" ", 8 - outType.ToString().Length).Aggregate((acc, item) => acc + item);
Console.WriteLine($"{spaces}{message}");
Console.ForegroundColor = backupForeground;
}
19
View Source File : HookInterceptorPreferences.cs
License : MIT License
Project Creator : AdamCarballo
License : MIT License
Project Creator : AdamCarballo
public void GenerateRandomSecureKey() {
var random = new System.Random();
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
_secureKey = new string(Enumerable.Repeat(chars, 10).Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : BigDecimal.cs
License : MIT License
Project Creator : AdamWhiteHat
License : MIT License
Project Creator : AdamWhiteHat
private static String ToString(BigInteger mantissa, int exponent, IFormatProvider provider)
{
if (provider == null) throw new ArgumentNullException();
if (mantissa == null || BigDecimalNumberFormatInfo == null) { return NullString; }
NumberFormatInfo formatProvider = NumberFormatInfo.GetInstance(provider);
bool negativeValue = (mantissa.Sign == -1);
bool negativeExponent = (Math.Sign(exponent) == -1);
string result = BigInteger.Abs(mantissa).ToString();
int absExp = Math.Abs(exponent);
if (negativeExponent)
{
if (absExp > result.Length)
{
int zerosToAdd = Math.Abs(absExp - result.Length);
string zeroString = string.Join(string.Empty, Enumerable.Repeat(formatProvider.NativeDigits[0], zerosToAdd));
result = zeroString + result;
result = result.Insert(0, formatProvider.NumberDecimalSeparator);
result = result.Insert(0, formatProvider.NativeDigits[0]);
}
else
{
int indexOfRadixPoint = Math.Abs(absExp - result.Length);
result = result.Insert(indexOfRadixPoint, formatProvider.NumberDecimalSeparator);
if (indexOfRadixPoint == 0)
{
result = result.Insert(0, formatProvider.NativeDigits[0]);
}
}
result = result.TrimEnd(new char[] { '0' });
if (result.Last().ToString() == formatProvider.NumberDecimalSeparator)
{
result = result.Substring(0, result.Length - 1);
}
}
else
{
string zeroString = string.Join(string.Empty, Enumerable.Repeat(formatProvider.NativeDigits[0], absExp));
result += zeroString;
}
if (negativeExponent) // Prefix "0."
{
}
if (negativeValue) // Prefix "-"
{
result = result.Insert(0, formatProvider.NegativeSign);
}
return result;
}
19
View Source File : SubjectControlTemplate.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
protected void AddChildItems(DropDownList dropDown, List<Enreplacedy> subjects, IEnumerable<Enreplacedy> children, int depth)
{
foreach (var child in children)
{
if (child == null)
{
continue;
}
var padding = HttpUtility.HtmlDecode(string.Concat(Enumerable.Repeat(" - ", depth)));
dropDown.Items.Add(new Lisreplacedem(string.Format("{0}{1}", padding, child.GetAttributeValue<string>("replacedle")), child.Id.ToString()));
var childId = child.Id;
var grandchildren = subjects.Where(s => s.GetAttributeValue<EnreplacedyReference>("parentsubject") != null && s.GetAttributeValue<EnreplacedyReference>("parentsubject").Id == childId).OrderBy(s => s.GetAttributeValue<string>("replacedle"));
depth++;
AddChildItems(dropDown, subjects, grandchildren, depth);
depth--;
}
}
19
View Source File : CrmSubjectDropDownList.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
protected void AddChildItems(List<Enreplacedy> subjects, IEnumerable<Enreplacedy> children, int depth)
{
foreach (var child in children)
{
if (child == null)
{
continue;
}
var padding = HttpUtility.HtmlDecode(string.Concat(Enumerable.Repeat(" - ", depth)));
Items.Add(new Lisreplacedem(string.Format("{0}{1}", padding, child.GetAttributeValue<string>("replacedle")), child.Id.ToString()));
var childId = child.Id;
var grandchildren = subjects.Where(s => s.GetAttributeValue<EnreplacedyReference>("parentsubject") != null && s.GetAttributeValue<EnreplacedyReference>("parentsubject").Id == childId).OrderBy(s => s.GetAttributeValue<string>("replacedle"));
depth++;
AddChildItems(subjects, grandchildren, depth);
depth--;
}
}
19
View Source File : StringUtilities.cs
License : MIT License
Project Creator : AdrianWilczynski
License : MIT License
Project Creator : AdrianWilczynski
public static string Repeat(this string text, int count)
=> string.Concat(Enumerable.Repeat(text, count));
19
View Source File : BloomTests.cs
License : MIT License
Project Creator : AElfProject
License : MIT License
Project Creator : AElfProject
[Fact]
public void AddHashAddValue_Test()
{
var empty = BytesValue.Parser.ParseFrom(ByteString.Empty);
var elf = new StringValue()
{
Value = "ELF"
}; // Serialized: 0a03454c46
// sha256 of empty string: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
// sha256 of 0a03454c46: 782330156f8c9403758ed30270a3e2d59e50b8f04c6779d819b72eee02addb13
var expected = string.Concat(
"0000000000000000000000000000100000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000040000000000000000",
"0000000000000000000100000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
"1000000000000000000000000000000000000000000000000000000800200000"
);
var bloom = new Bloom();
bloom.AddSha256Hash(
ByteArrayHelper.HexStringToByteArray("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"));
bloom.AddSha256Hash(
ByteArrayHelper.HexStringToByteArray("782330156f8c9403758ed30270a3e2d59e50b8f04c6779d819b72eee02addb13"));
replacedert.Equal(expected, bloom.Data.ToHex().Replace("0x", ""));
new Bloom(bloom).Data.ShouldBe(bloom.Data);
// add value
var bloom1 = new Bloom();
bloom1.AddValue(empty);
bloom1.AddValue(elf);
replacedert.Equal(expected, bloom1.Data.ToHex().Replace("0x", ""));
// Take only 12 characters (2 * 3 = 6 bytes)
var bloom2 = new Bloom();
var fiftyTwoZeros = string.Join("", Enumerable.Repeat("0", 52));
// Too short
replacedert.ThrowsAny<Exception>(() => bloom2.AddSha256Hash(ByteArrayHelper.HexStringToByteArray("e3b0c44298fc")));
replacedert.ThrowsAny<Exception>(() => bloom2.AddSha256Hash(ByteArrayHelper.HexStringToByteArray("782330156f8c")));
// Too long
replacedert.ThrowsAny<Exception>(() =>
bloom2.AddSha256Hash(ByteArrayHelper.HexStringToByteArray("e3b0c44298fc" + "00" + fiftyTwoZeros)));
replacedert.ThrowsAny<Exception>(() =>
bloom2.AddSha256Hash(ByteArrayHelper.HexStringToByteArray("782330156f8c" + "00" + fiftyTwoZeros)));
// Right size
bloom2.AddSha256Hash(ByteArrayHelper.HexStringToByteArray("e3b0c44298fc" + fiftyTwoZeros));
bloom2.AddSha256Hash(ByteArrayHelper.HexStringToByteArray("782330156f8c" + fiftyTwoZeros));
replacedert.Equal(expected, bloom2.Data.ToHex().Replace("0x", ""));
// Incorrect value
var bloom3 = new Bloom();
bloom3.AddSha256Hash(ByteArrayHelper.HexStringToByteArray("e3b0c44298f0" + fiftyTwoZeros));
bloom3.AddSha256Hash(ByteArrayHelper.HexStringToByteArray("782330156f80" + fiftyTwoZeros));
replacedert.NotEqual(expected, bloom3.Data.ToHex().Replace("0x", ""));
}
19
View Source File : IdEncoder.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
License : Mozilla Public License 2.0
Project Creator : agebullhu
private static void Encoding(long segment, int maxLength, StringBuilder stringBuilder)
{
var buildStack = new Stack<string>();
while (true)
{
var index = segment % SmallFlakes.elements.Length;
buildStack.Push(SmallFlakes.elements[index]);
segment = segment / SmallFlakes.elements.Length;
if (segment == 0)
{
break;
}
}
foreach (var padLeft in Enumerable.Repeat("0", maxLength - buildStack.Count))
{
buildStack.Push(padLeft);
}
foreach (var element in buildStack)
{
stringBuilder.Append(element);
}
}
19
View Source File : Platform.Posix.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
License : Mozilla Public License 2.0
Project Creator : agebullhu
public static UnmanagedLibrary LoadUnmanagedLibrary(string libraryName)
{
if (string.IsNullOrWhiteSpace(libraryName))
{
throw new ArgumentException("A valid library name is expected.", nameof(libraryName));
}
// Now look: This method should ExpandPaths on LibraryPaths.
// That being said, it should just enumerate
// Path, AppBase, Arch, Compiler, LibraryName, Extension
// Secondly, this method should try each /lib/x86_64-linux-gnu/libload.so.2 to load,
// Third, this method should try EmbeddedResources,
// Finally, this method fails, telling the user all libraryPaths searched.
var libraryPaths = new List<string>(Platform.LibraryPaths);
Platform.ExpandPaths(libraryPaths, "{Path}", EnumerateLibLdConf("/etc/ld.so.conf"));
var PATHs = new List<string>();
PATHs.Add(EnsureNotEndingSlash(Path.GetDirectoryName(replacedembly.GetExecutingreplacedembly().Location)));
PATHs.AddRange(EnumerateLibLdPATH());
Platform.ExpandPaths(libraryPaths, "{DllPath}", PATHs.ToArray());
Platform.ExpandPaths(libraryPaths, "{AppBase}", EnsureNotEndingSlash(
AppDomain.CurrentDomain.BaseDirectory));
Platform.ExpandPaths(libraryPaths, "{LibraryName}", libraryName);
// Platform.ExpandPaths(libraryPaths, "{Ext}", Platform.LibraryFileExtension);
string architecture;
string[] architecturePaths = null;
if (Platform.Architecture == ImageFileMachine.I386 && Environment.Is64BitProcess)
{
architecture = "amd64";
}
else {
architecture = Enum.GetName(typeof(ImageFileMachine), Platform.Architecture).ToLower();
}
if (architecture == "i386") architecturePaths = new string[] { "i386", "x86" };
if (architecture == "amd64") architecturePaths = new string[] { "amd64", "x64" };
if (architecturePaths == null) architecturePaths = new string[] { architecture };
Platform.ExpandPaths(libraryPaths, "{Arch}", architecturePaths);
// Expand Compiler
Platform.ExpandPaths(libraryPaths, "{Compiler}", Platform.Compiler);
// Now TRY the enumerated Directories for libFile.so.*
string traceLabel = string.Format("UnmanagedLibrary[{0}]", libraryName);
foreach (string libraryPath in libraryPaths)
{
IEnumerable<string> files;
if (libraryPath.Contains("/"))
{
string folder = null;
string filesPattern = libraryPath;
int filesPatternI;
if (-1 < (filesPatternI = filesPattern.LastIndexOf('/')))
{
folder = filesPattern.Substring(0, filesPatternI + 1);
filesPattern = filesPattern.Substring(filesPatternI + 1);
}
if (string.IsNullOrEmpty(folder) || !Directory.Exists(folder)) continue;
files = Directory.EnumerateFiles(folder, filesPattern, SearchOption.TopDirectoryOnly).ToArray();
}
else
{
files = Enumerable.Repeat(libraryPath, 1);
}
foreach (string file in files)
{
// Finally, I am really loading this file
SafeLibraryHandle handle = OpenHandle(file);
if (!handle.IsNullOrInvalid())
{
// This is Platform.Posix. In mono, just dlopen'ing the library doesn't work.
// Using DllImport("__Internal", EntryPoint = "mono_dllmap_insert") to get mono on the path.
MonoDllMapInsert(libraryName, file);
Trace.TraceInformation(string.Format("{0} Loaded binary \"{1}\"",
traceLabel, file));
return new UnmanagedLibrary(libraryName, handle);
}
else
{
Exception nativeEx = GetLastLibraryError();
Trace.TraceInformation(string.Format("{0} Custom binary \"{1}\" not loaded: {2}",
traceLabel, file, nativeEx.Message));
}
}
}
// Search ManifestResources for fileName.arch.ext
// TODO: Enumerate ManifestResources for ZeroMQ{Arch}{Compiler}{LibraryName}{Ext}.so.*
string resourceName = string.Format("ZeroMQ.{0}.{1}{2}", libraryName, architecture, ".so");
string tempPath = Path.Combine(Path.GetTempPath(), resourceName);
if (ExtractManifestResource(resourceName, tempPath))
{
// TODO: need syscall_chmod_execute(path); ?
SafeLibraryHandle handle = OpenHandle(tempPath);
if (!handle.IsNullOrInvalid())
{
MonoDllMapInsert(libraryName, tempPath);
Trace.TraceInformation(string.Format("{0} Loaded binary from EmbeddedResource \"{1}\" from \"{2}\".",
traceLabel, resourceName, tempPath));
return new UnmanagedLibrary(libraryName, handle);
}
else
{
Trace.TraceWarning(string.Format("{0} Unable to run the extracted EmbeddedResource \"{1}\" from \"{2}\".",
traceLabel, resourceName, tempPath));
}
}
else
{
Trace.TraceWarning(string.Format("{0} Unable to extract the EmbeddedResource \"{1}\" to \"{2}\".",
traceLabel, resourceName, tempPath));
}
var fnf404 = new StringBuilder();
fnf404.Append(traceLabel);
fnf404.Append(" Unable to load binary \"");
fnf404.Append(libraryName);
fnf404.AppendLine("\" from folders");
foreach (string path in libraryPaths)
{
fnf404.Append("\t");
fnf404.AppendLine(path);
}
fnf404.Append(" Also unable to load binary from EmbeddedResource \"");
fnf404.Append(resourceName);
fnf404.Append("\", from temporary path \"");
fnf404.Append(tempPath);
fnf404.Append("\". See Trace output for more information.");
throw new FileNotFoundException(fnf404.ToString());
}
19
View Source File : DBEntryCoalition.cs
License : GNU General Public License v3.0
Project Creator : akaAgar
License : GNU General Public License v3.0
Project Creator : akaAgar
internal string[] GetRandomUnits(UnitFamily family, Decade decade, int count, List<string> unitMods, bool useDefaultList = true)
{
// Count is zero, return an empty array.
if (count < 1) return new string[0];
UnitCategory category = family.GetUnitCategory();
bool allowDifferentUnitTypes = false;
switch (category)
{
// Units are planes or helicopters, make sure unit count does not exceed the maximum flight group size
case UnitCategory.Helicopter:
case UnitCategory.Plane:
count = Toolbox.Clamp(count, 1, Toolbox.MAXIMUM_FLIGHT_GROUP_SIZE);
break;
// Units are ships or static buildings, only one unit per group (that's the law in DCS World, buddy)
case UnitCategory.Ship:
case UnitCategory.Static:
count = 1;
break;
// Units are ground vehicles, allow multiple unit types in the group
case UnitCategory.Vehicle:
allowDifferentUnitTypes = true;
break;
}
string[] validUnits = SelectValidUnits(family, decade, unitMods, useDefaultList);
// Different unit types allowed in the group, pick a random type for each unit.
if (allowDifferentUnitTypes)
{
List<string> selectedUnits = new List<string>();
for (int i = 0; i < count; i++)
selectedUnits.Add(Toolbox.RandomFrom(validUnits));
return selectedUnits.ToArray();
}
// Different unit types NOT allowed in the group, pick a random type and fill the whole array with it.
else
{
string unit = Toolbox.RandomFrom(validUnits);
return Enumerable.Repeat(unit, count).ToArray();
}
}
19
View Source File : IndentationHelper.cs
License : Apache License 2.0
Project Creator : alexyakunin
License : Apache License 2.0
Project Creator : alexyakunin
public static string CreateIndentString() => string.Concat(Enumerable.Repeat(" ", IndentSize));
19
View Source File : TestConfig.cs
License : MIT License
Project Creator : aliyun
License : MIT License
Project Creator : aliyun
public static string RandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[myRandom.Next(s.Length)]).ToArray());
}
19
View Source File : OAuthController.cs
License : GNU General Public License v3.0
Project Creator : AniAPI-Team
License : GNU General Public License v3.0
Project Creator : AniAPI-Team
private string generateCode()
{
const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, 30)
.Select(s => s[_random.Next(s.Length)]).ToArray());
}
19
View Source File : DocumentSerializerTest.cs
License : MIT License
Project Creator : ap0llo
License : MIT License
Project Creator : ap0llo
[Fact]
public void Ordered_lists_with_more_than_10_items_are_serialized_as_expected() =>
replacedertToStringEquals(
"1. Item\r\n" +
"2. Item\r\n" +
"3. Item\r\n" +
"4. Item\r\n" +
"5. Item\r\n" +
"6. Item\r\n" +
"7. Item\r\n" +
"8. Item\r\n" +
"9. Item\r\n" +
"10. Item\r\n" +
"11. Item\r\n",
new MdDoreplacedent(
new MdOrderedList(Enumerable.Repeat("Item", 11).Select(x => new MdLisreplacedem(x)))
)
);
19
View Source File : Common.cs
License : MIT License
Project Creator : arafattehsin
License : MIT License
Project Creator : arafattehsin
public static string GenerateReferenceID(int length)
{
Random random = new Random();
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : SmogonGenner.cs
License : MIT License
Project Creator : architdate
License : MIT License
Project Creator : architdate
private string alertText(string showdownSpec, int count, Dictionary<string, List<string>> replacedles)
{
string alertText = showdownSpec + ":" + String.Concat(Enumerable.Repeat(Environment.NewLine, 2));
foreach(KeyValuePair<string, List<string>> entry in replacedles)
{
alertText += string.Format("{0}: {1}\n", entry.Key, string.Join(", ", entry.Value));
}
alertText += Environment.NewLine + count.ToString() + " sets genned for " + showdownSpec;
return alertText;
}
19
View Source File : Util.cs
License : MIT License
Project Creator : arcus-azure
License : MIT License
Project Creator : arcus-azure
public static string GetRandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random = new Random();
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : StringUtilities.cs
License : MIT License
Project Creator : armanab
License : MIT License
Project Creator : armanab
public virtual string GenerateRandom(int length, string chars)
{
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : RandomGenerator.cs
License : MIT License
Project Creator : armutcom
License : MIT License
Project Creator : armutcom
private static string RandomAlphanumeric(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length).Select(s => s[Random.Next(s.Length)]).ToArray());
}
19
View Source File : RoslynGuardTests.cs
License : MIT License
Project Creator : ashmind
License : MIT License
Project Creator : ashmind
[Fact]
public void ThrowsGuardException_ForLongFluentCall() {
// https://github.com/dotnet/roslyn/issues/9795
var code = string.Join(".", Enumerable.Repeat("M()", 1000));
replacedert.Throws<RoslynGuardException>(
() => CSharpRoslynGuard.Validate(code)
);
}
19
View Source File : Playlists.cs
License : MIT License
Project Creator : Assistant
License : MIT License
Project Creator : Assistant
private static string TextProgress(int min, int max, int value)
{
if (max == value)
{
return $" {string.Concat(Enumerable.Repeat("▒", 10))} [{value}/{max}]";
}
int interval = (int)Math.Floor((double)value / (((double)max - (double)min) / (double)10));
return $" {string.Concat(Enumerable.Repeat("▒", interval))}{string.Concat(Enumerable.Repeat("░", 10 - interval))} [{value}/{max}]";
}
19
View Source File : ExtentLogConsumer.cs
License : Apache License 2.0
Project Creator : atata-framework
License : Apache License 2.0
Project Creator : atata-framework
private static string NormalizeMessage(string message)
{
message = HttpUtility.HtmlEncode(message)
.Replace(Environment.NewLine, "<br>");
return Regex.Replace(
message,
@"(?<=\<br\>)\s+",
match => string.Concat(Enumerable.Repeat(" ", match.Length)));
}
19
View Source File : TestUtility.cs
License : Apache License 2.0
Project Creator : awslabs
License : Apache License 2.0
Project Creator : awslabs
public static string RandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,. ";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[Utility.Random.Next(s.Length)]).ToArray());
}
19
View Source File : LogSimulator.cs
License : Apache License 2.0
Project Creator : awslabs
License : Apache License 2.0
Project Creator : awslabs
public static string RandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,. ";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : AsyncDirectorySourceBookmarkTest.cs
License : Apache License 2.0
Project Creator : awslabs
License : Apache License 2.0
Project Creator : awslabs
private void WriteLine(string file, string text, int count = 1, bool truncate = false)
{
var lines = Enumerable.Repeat(text, count).ToArray();
var filePath = Path.Combine(_testDir, file);
if (truncate)
{
File.WriteAllLines(filePath, lines);
}
else
{
File.AppendAllLines(filePath, lines);
}
}
19
View Source File : AsyncBatchQueueTest_Secondary.cs
License : Apache License 2.0
Project Creator : awslabs
License : Apache License 2.0
Project Creator : awslabs
[Theory]
[InlineData(0)]
[InlineData(1)]
[InlineData(100)]
public async Task InMemoryQueue_PushAndGet(int batchCount)
{
var secondary = new InMemoryQueue<List<string>>(10);
var q = new AsyncBatchQueue<string>(1000,
new long[] { batchCount },
new Func<string, long>[] { s => 1 }, secondary);
await q.PushSecondaryAsync(Enumerable.Repeat("a", batchCount + 1).ToList());
var output = new List<string>();
var getTask = q.GetNextBatchAsync(output, 10 * 1000).AsTask();
replacedert.True(getTask.Wait(1000));
replacedert.Equal(batchCount, output.Count);
if (batchCount == 0)
{
return;
}
// second call should return the last item
output.Clear();
await q.GetNextBatchAsync(output, 100);
replacedert.Single(output);
}
19
View Source File : WorkerHostBuilderExtensionsTests.cs
License : MIT License
Project Creator : Azure
License : MIT License
Project Creator : Azure
[Theory]
[InlineData(0)]
[InlineData(1)]
public void RegisterCommandLine_NoArgs(int count)
{
var args = Enumerable.Repeat<string>("test", count).ToArray();
var configBuilder = new ConfigurationBuilder();
WorkerHostBuilderExtensions.RegisterCommandLine(configBuilder, args);
// Ensures we don't throw an IndexOutOfRangeException; no replacedert necessary.
configBuilder.Build();
}
19
View Source File : Helper.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
public static string RandomString(int length)
{
Random random = new Random();
const string chars = "HMN34P67R9TWCXYF";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : ImageGenerator.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
private static string RandomString(int length)
{
Random random = new Random();
const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : Utility.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
public static string RandomAString(int length, Random random)
{
const string chars = "abcdefghijklmnopqrstuvwxyz";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : Utils.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
public static string RandomString(int length)
{
var random = new Random();
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : Utility.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
public static string RandomString(int length, Random random)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : SharpPsExec.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
License : BSD 3-Clause "New" or "Revised" License
Project Creator : b4rtik
private static string RandomString(int length)
{
const string chars = "abcdefghijklmnopqrstuvwxyz0123456789";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : Security.cs
License : MIT License
Project Creator : b9q
License : MIT License
Project Creator : b9q
private static string random_string(int length)
{
Random random = new Random();
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : Program.cs
License : MIT License
Project Creator : b9q
License : MIT License
Project Creator : b9q
public static void randomize_replacedle(this Form f)
{
Random rnd = new Random();
const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
f.Text = new string(Enumerable.Repeat(chars, rnd.Next(10, 20))
.Select(s => s[rnd.Next(s.Length)]).ToArray());
}
19
View Source File : Program.cs
License : MIT License
Project Creator : b9q
License : MIT License
Project Creator : b9q
private static string random_string()
{
Random random = new Random();
return new string((from s in Enumerable.Repeat<string>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 16)
select s[random.Next(s.Length)]).ToArray<char>());
}
19
View Source File : Program.cs
License : MIT License
Project Creator : backtrace-labs
License : MIT License
Project Creator : backtrace-labs
private string GetRandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var tempString = Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray();
return new string(tempString);
}
19
View Source File : Program.cs
License : MIT License
Project Creator : backtrace-labs
License : MIT License
Project Creator : backtrace-labs
private string GetRandomString(int length)
{
Random random = new Random();
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var tempString = Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray();
return new string(tempString);
}
19
View Source File : HtmlAsyncTests.cs
License : MIT License
Project Creator : benjamin-hodgson
License : MIT License
Project Creator : benjamin-hodgson
[Fact]
public async Task LongText()
{
{
var expected = new string('a', 10000);
Html html = expected;
replacedert.Equal(expected, await GetStringAsync(html));
}
{
var expected = string.Concat(Enumerable.Repeat("abcdefghijkl", 5000));
Html html = expected;
replacedert.Equal(expected, await GetStringAsync(html));
}
}
19
View Source File : HtmlAsyncTests.cs
License : MIT License
Project Creator : benjamin-hodgson
License : MIT License
Project Creator : benjamin-hodgson
[Fact]
public async Task TextEscaping_Long()
{
Html html = string.Concat(Enumerable.Repeat("<>\"&'", 10000));
var expected = string.Concat(Enumerable.Repeat("<>"&'", 10000));
replacedert.Equal(expected, await GetStringAsync(html));
}
19
View Source File : HtmlTests.cs
License : MIT License
Project Creator : benjamin-hodgson
License : MIT License
Project Creator : benjamin-hodgson
[Fact]
public void LongText()
{
{
var expected = new string('a', 10000);
Html html = expected;
replacedert.Equal(expected, html.ToString());
}
{
var expected = string.Concat(Enumerable.Repeat("abcdefghijkl", 5000));
Html html = expected;
replacedert.Equal(expected, html.ToString());
}
}
19
View Source File : HtmlTests.cs
License : MIT License
Project Creator : benjamin-hodgson
License : MIT License
Project Creator : benjamin-hodgson
[Fact]
public void TextEscaping_Long()
{
Html html = string.Concat(Enumerable.Repeat("<>\"&'", 10000));
var expected = string.Concat(Enumerable.Repeat("<>"&'", 10000));
replacedert.Equal(expected, html.ToString());
}
19
View Source File : JsonBench.cs
License : MIT License
Project Creator : benjamin-hodgson
License : MIT License
Project Creator : benjamin-hodgson
public static string RandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
19
View Source File : ToNullableTests.cs
License : MIT License
Project Creator : bert2
License : MIT License
Project Creator : bert2
[Fact] public void ReturnsValueWhenGivenSingletonEnumerable()
=> Enumerable.Repeat("hi", 1).ToNullable().ShouldBe("hi");
19
View Source File : ToNullableTests.cs
License : MIT License
Project Creator : bert2
License : MIT License
Project Creator : bert2
[Fact]
public void ThrowsWhenGivenEnumerableWithMoreThanOneItem() => new Action(() =>
Enumerable.Repeat("hi", 2).ToNullable())
.ShouldThrow<InvalidOperationException>();
See More Examples