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
//copied from here | |
//https://stackoverflow.com/questions/29137708/how-to-delete-all-the-documents-in-documentdb-through-c-sharp-code | |
//https://stackoverflow.com/questions/43587572/how-to-clear-the-collection-in-documentdb-through-query-explorer | |
/** | |
* A DocumentDB stored procedure that bulk deletes documents for a given query.<br/> | |
* Note: You may need to execute this sproc multiple times (depending whether the sproc is able to delete every document within the execution timeout limit). | |
* | |
* @function | |
* @param {string} query - A query that provides the documents to be deleted (e.g. "SELECT * FROM c WHERE c.founded_year = 2008") |
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); |
NewerOlder