This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static async Task<IRemainingWorkEstimator> CreateEstimatorAsync(string uri, string key, string collection) | |
{ | |
IChangeFeedDocumentClient dbClient = new ChangeFeedDocumentClient(new DocumentClient(new Uri(uri), key)); | |
dbClient = new QoSMeteringChangeFeedDocumentClient(dbClient, new QoSMeteringReporter()); | |
var builder = new ChangeFeedProcessorBuilder() | |
.WithObserver<ConsoleObserver>() | |
.WithHostName("console_app_host") | |
.WithFeedCollection(new DocumentCollectionInfo() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string UsingSpanBase64BinaryGuid(Guid oid, params string[] input) | |
{ | |
var totalUtf8Bytes = _guidSize; | |
for (int i = 0; i < input.Length; i++) | |
{ | |
totalUtf8Bytes += Encoding.UTF8.GetByteCount(input[i]); | |
} | |
Span<byte> resultSpan = stackalloc byte[Base64.GetMaxEncodedToUtf8Length(totalUtf8Bytes)]; | |
if (!MemoryMarshal.TryWrite(resultSpan, ref oid)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string UsingSpanBase64(Guid oid, params string[] input) | |
{ | |
var totalUtf8Bytes = 36; // GUID.Format(D) = 36 bytes | |
for (int i = 0; i < input.Length; i++) | |
{ | |
totalUtf8Bytes += Encoding.UTF8.GetByteCount(input[i]); | |
} | |
Span<byte> resultSpan = stackalloc byte[Base64.GetMaxEncodedToUtf8Length(totalUtf8Bytes)]; | |
if (!Utf8Formatter.TryFormat(oid, resultSpan, out int writtenBytes) || writtenBytes != 36) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string UsingWebEncoders(string input) | |
{ | |
byte[] inputBytes = null; | |
char[] outputChars = null; | |
try | |
{ | |
var minimumLength = Encoding.UTF8.GetByteCount(input); | |
inputBytes = ArrayPool<byte>.Shared.Rent(minimumLength); | |
int inputBytesCount = Encoding.UTF8.GetBytes(input, 0, input.Length, inputBytes, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[GlobalSetup] | |
public void GlobalSetup() | |
{ | |
var rnd = new Random(); | |
_guid = Guid.NewGuid(); | |
var buffer = new byte[DataLen]; | |
rnd.NextBytes(buffer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
CreateWebHostBuilder(args).Build().Run(); | |
} | |
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | |
WebHost | |
.CreateDefaultBuilder(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Route("api/[controller]")] | |
[ApiController] | |
public class ValuesController : ControllerBase | |
{ | |
private readonly ILogger<ValuesController> _logger; | |
public ValuesController(ILogger<ValuesController> logger) | |
{ | |
_logger = logger ?? throw new ArgumentNullException(nameof(logger)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Logging": { | |
"LogLevel": { | |
"Default": "Verbose" | |
}, | |
"ScopeLevel": { | |
"ScopeFilteringWebApplication": "PlainText", | |
"Default": "None" | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Logging": { | |
"LogLevel": { | |
"Default": "Verbose" | |
} | |
}, | |
"AllowedHosts": "*" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static async Task Main(string[] args) | |
{ | |
Console.WriteLine("Starting, press a key to continue ..."); | |
Console.ReadKey(); | |
var ips = await Dns.GetHostAddressesAsync("www.google.com"); | |
foreach (var ipAddress in ips) |
NewerOlder