using System;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
var browser = new Browser();
browser.Bruh += (s, e) =>
{
Console.WriteLine("YAY");
browser.ClearEvents();
};
browser.Go();
browser.Go();
browser.Go();
}
}
class Browser
{
public event EventHandler Bruh;
public void Go()
{
Console.WriteLine("GO");
Bruh?.Invoke(this, null);
}
public void ClearEvents()
{
Bruh = null;
}
}
}
public class RedirectToNoWwwRule : IRule
{
public virtual void ApplyRule(RewriteContext context)
{
var req = context.HttpContext.Request;
if (req.Host.Host.Equals("localhost", StringComparison.OrdinalIgnoreCase))
{
context.Result = RuleResult.ContinueRules;
return;
}
if (!req.Host.Value.StartsWith("www.", StringComparison.OrdinalIgnoreCase))
{
context.Result = RuleResult.ContinueRules;
return;
}
var NoWwwHost = new HostString(req.Host.Value.Substring(4));
var newUrl = UriHelper.BuildAbsolute(req.Scheme, NoWwwHost , req.PathBase, req.Path, req.QueryString);
var response = context.HttpContext.Response;
response.StatusCode = 301;
response.Headers[HeaderNames.Location] = newUrl;
context.Result = RuleResult.EndResponse;
}
}
public static class RewriteOptionsExtensions
{
public static RewriteOptions AddRedirectNoWww(this RewriteOptions options)
{
options.Rules.Add(new RedirectToNoWwwRule());
return options;
}
}
var options = new RewriteOptions();
options.AddRedirectNoWww();
app.UseRewriter(options);
using System;
using System.Security.Cryptography;
using System.Text;
namespace ConsoleApp12
{
class Program
{
const int SIZE = 17;
static void Main(string[] args)
{
Console.WriteLine("Введите начало последовательности: ");
var source = Console.ReadLine();
var randomString = GenerateNumbers(SIZE - source.Length);
var result = $"{source}{randomString}";
Console.WriteLine(result);
Console.ReadKey();
}
static string GenerateNumbers(int len)
{
if (len <= 0) return "";
using var crypto = new RNGCryptoServiceProvider();
Span<byte> buffer = stackalloc byte[len];
crypto.GetBytes(buffer);
var sb = new StringBuilder(len);
foreach (var item in buffer)
{
sb.Append(item % 10);
}
return sb.ToString();
}
}
}
int SIZE = 10 * 1024;
BinaryReader binReader = new BinaryReader("{FILE}");
binReader.BaseStream.Position = FileSize - SIZE;
byte[] array = binReader.ReadBytes(SIZE);
var whiteList = new string[] { "..." };
webBrowser1.Navigate("https://google.com");
webBrowser1.Navigating += (s, arg) =>
{
if (!whiteList.Any(x => x == arg.Url.ToString())) arg.Cancel = true;
};