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 VisaCheckoutDecryptor | |
{ | |
private const int HMAC_LENGTH = 32, IV_LENGTH = 16; | |
public static string DecryptPayload(string key, string dynamicKey, string payload) | |
{ | |
var payloadData = Convert.FromBase64String(payload); | |
var dynamicKeyData = Convert.FromBase64String(dynamicKey); | |
var keyData = Encoding.UTF8.GetBytes(key); |
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 TransactionRepository : RiakTSRepository<TestTransaction> | |
{ | |
protected override string TableName => "Transaction"; | |
protected override IEnumerable<Column> Columns | |
{ | |
get | |
{ | |
var columns = new[] | |
{ |
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 namespace System.Management.Automation | |
using namespace System.Management.Automation.Language | |
if ($host.Name -eq 'ConsoleHost') | |
{ | |
Import-Module PSReadLine | |
} | |
oh-my-posh --init --shell pwsh --config C:/Github/prompt/oh-my-posh.json | Invoke-Expression |
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 interface IEventPublisher | |
{ | |
void Publish<T>(T item) where T : IEvent; | |
} | |
public interface IHandler<in T> where T : IEvent | |
{ | |
void Handle(T item); | |
} |
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 void Main(string[] args) | |
{ | |
Run().Wait(); | |
} | |
private static async Task Run() | |
{ | |
var client = new MongoClient("mongodb://localhost:27016"); |
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 | |
{ | |
static void Main(string[] args) | |
{ | |
var client = new MongoClient("mongodb://localhost:27016"); | |
try | |
{ | |
var server = client.GetServer(); | |
var database = server.GetDatabase("testv1"); |
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 class MongoUnitOfWork | |
{ | |
public static async Task Transaction(this IMongoDatabase database, Func<Task> commands) | |
{ | |
if (database == null) throw new ArgumentNullException("database"); | |
var commited = false; | |
var beginTransaction = new BsonDocument("beginTransaction", "true"); | |
await database.RunCommandAsync<BsonDocument>(beginTransaction); |
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
/// <summary> | |
/// Used to simplify testing routes and restful testing routes | |
/// <example> | |
/// This tests that incoming PUT on resource is handled by the update method of the Banner controller | |
/// "~/banner/1" | |
/// .WithMethod(HttpVerbs.Put) | |
/// .ShouldMapTo<BannerController>(action => action.Update(1)); | |
/// </example> | |
/// </summary> | |
public static class RouteTestingExtensions |
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 Stream ToStream(this string str) | |
{ | |
byte[] byteArray = Encoding.UTF8.GetBytes(str); | |
//byte[] byteArray = Encoding.ASCII.GetBytes(str); | |
return new MemoryStream(byteArray); | |
} | |
public static string ToString(this Stream stream) | |
{ | |
var reader = new StreamReader(stream); | |
return reader.ReadToEnd(); |
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 bool Between(this DateTime dt, DateTime rangeBeg, DateTime rangeEnd) | |
{ | |
return dt.Ticks >= rangeBeg.Ticks && dt.Ticks <= rangeEnd.Ticks; | |
} | |
public static int CalculateAge(this DateTime dateTime) | |
{ | |
var age = DateTime.Now.Year - dateTime.Year; | |
if (DateTime.Now < dateTime.AddYears(age)) | |
age--; |