Tindi.Random.Library
1.0.4
dotnet add package Tindi.Random.Library --version 1.0.4
NuGet\Install-Package Tindi.Random.Library -Version 1.0.4
<PackageReference Include="Tindi.Random.Library" Version="1.0.4" />
paket add Tindi.Random.Library --version 1.0.4
#r "nuget: Tindi.Random.Library, 1.0.4"
// Install Tindi.Random.Library as a Cake Addin #addin nuget:?package=Tindi.Random.Library&version=1.0.4 // Install Tindi.Random.Library as a Cake Tool #tool nuget:?package=Tindi.Random.Library&version=1.0.4
Simple random library to generate random value from given range, character, guid, string, byte[]
Tindi.Random sample usage:
using Microsoft.Extensions.DependencyInjection; using Tindi.Random.Library; Console.WriteLine("Hello, World!");
Tindi.Random.Library.Startup.Init(); var randomServiceDI = Tindi.Random.Library.Startup.ServiceProvider.GetService<IRandom>(); Console.WriteLine(randomServiceDI.GetCharCapitalLetter());
//var randomService = new Tindi.Random.Library.Random();
Console.WriteLine(randomServiceDI.GetInteger(200, 100, 150)); Console.WriteLine(randomServiceDI.GetGuid().ToString());
string code = "";
for (int i = 0; i < 6; i++) { code = code + randomServiceDI.GetCharDigit(); }
Console.WriteLine(code); Console.ReadLine();
************* MORE SOPHISTICATED SAMPLE *************** // See https://aka.ms/new-console-template for more information using Microsoft.Extensions.DependencyInjection; using Tindi.Email.Library; using Tindi.Random.Library; using Tindi.PasswordValidator.Library;
ServiceProvider serviceProvider;
serviceProvider = new ServiceCollection() .ConfigureTindiMailingSystem() .ConfigureTindiPasswordValidatorLibrary() .ConfigureTindiRandomLibrary() .AddScoped<sample>() .BuildServiceProvider();
Console.WriteLine("Hello start");
//Tindi.Email.Library.Startup.Init(); //var emailService = Tindi.Email.Library.Startup.ServiceProvider.GetService<IEmail>();
var emailService = serviceProvider.GetService<IEmail>(); var passwordValidatorService = serviceProvider.GetService<IPasswordValidator>(); var randomService = serviceProvider.GetService<IRandom>();
bool isValidPassword = passwordValidatorService.IsValid("dupa#43"); if (isValidPassword == false) { foreach (var item in passwordValidatorService.failedChecks) { Console.WriteLine(item); } }
var newRandom = serviceProvider.GetService<sample>(); newRandom.GenerateRandom();
Console.WriteLine(randomService.GetInteger(100).ToString());
emailService.RegisterSenderDetails("smtp.gmail.com", 587, "xxxx@gmail.com", "yourapplicationGmailPasswordSettableInYourGoogleAccount"); emailService.ComposeMailMessage("youremail@something.com", "sent from:)", "First experiments"); emailService.Send();
Console.WriteLine("sent"); Console.ReadLine();
public class sample {
private IRandom random; public sample(IRandom random) { this.random = random; }
public void GenerateRandom() { Console.WriteLine(random.GetCharCapitalLetter()); } }
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.Extensions.DependencyInjection (>= 6.0.0)
- Microsoft.Extensions.Logging (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added generating random bytes [] and random string of specific length