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
{policy} = "Azure Password Reset Policy"; | |
{0} = "B2C directory name"; | |
{client_id} = B2C Client Id; | |
https://{0}.b2clogin.com/{0}.onmicrosoft.com/oauth2/v2.0/authorize?p={policy}&client_id=&redirect_uri=https://localhost:44310/oauth/passwordresetresponse&scope=openid&response_type=id_token&prompt=login&response_mode=form_post |
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
using System; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
var x = new CardExpiryValidator("10/2021"); | |
Console.WriteLine(x.IsExpired); | |
} | |
} |
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 bool PassesLuhnTest(string cardNumber) | |
{ | |
ReadOnlySpan<char> value = cardNumber; | |
var sum = 0; | |
var isDouble = false; | |
for (var i = value.Length - 1; i >= 0; i--) | |
{ | |
int digit; |
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
internal static class QueryBuilder | |
{ | |
internal static string Build(string uri, IDictionary<string, string> queryString) | |
{ | |
var sb = new StringBuilder(uri); | |
var hasQuery = uri.IndexOf('?') != -1; | |
foreach (var item in queryString) | |
{ |
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 sealed class BearerPolicyEvaluator : IPolicyEvaluator | |
{ | |
private const string Scheme = "Bearer"; | |
public Task<AuthenticateResult> AuthenticateAsync(AuthorizationPolicy _, HttpContext context) | |
{ | |
if (!context.Request.Headers.ContainsKey("Authorization")) | |
return Task.FromResult(AuthenticateResult.Fail("No Authorization header found!")); | |
string authHeader = context.Request.Headers["Authorization"]; |
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 sealed class JsonContent : StreamContent | |
{ | |
private static MediaTypeHeaderValue JsonMediaType => new MediaTypeHeaderValue("application/json"); | |
public JsonContent(Stream stream) : base(stream) | |
{ | |
Headers.ContentType = JsonMediaType; | |
} | |
public static JsonContent Create(object value) |
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
using System; | |
using System.Collections.Generic; | |
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Order; | |
using BenchmarkDotNet.Running; | |
namespace App | |
{ | |
public sealed class Program | |
{ |
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
//Insert new record to database | |
public interface ICreatableRepository<T> | |
{ | |
int Create(T value); | |
} | |
//List records | |
public interface IListableRepository<T> | |
{ | |
IList<T> List(DataParameterDictionary dataParameters); |
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
internal static class FeedPagerService | |
{ | |
private const int PageSize = 10; | |
internal static (List<FeedItem> feeds, int pageSize, int maxRecords) SkipRecords(int pageIndex, List<FeedItem> feeds) | |
{ | |
if (pageIndex < 0) pageIndex = 0; //fix negative | |
var startPage = pageIndex <= 1 ? 0 : (pageIndex - 1) * PageSize; |
NewerOlder