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
/* Original source: https://stackoverflow.com/a/74454347/399845 */ | |
SET QUOTED_IDENTIFIER ON | |
SET ARITHABORT ON | |
SET NUMERIC_ROUNDABORT OFF | |
SET CONCAT_NULL_YIELDS_NULL ON | |
SET ANSI_NULLS ON | |
SET ANSI_PADDING ON | |
SET ANSI_WARNINGS ON | |
DECLARE @TableName varchar(255); |
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 readonly struct Result<T>(bool successful, T result, Exception exception) | |
{ | |
private bool Successful { get; } = successful; | |
public static implicit operator T(Result<T> wrapped) => wrapped.UnwrapOrThrow(); | |
public static implicit operator Result<T>(T result) => new(true, result, default!); | |
public static implicit operator Result<T>(Exception error) => new(false, default!, error); | |
/// <summary> | |
/// Get backing value and convert it to another type |
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
version: "3.9" | |
name: common-services | |
services: | |
dbserver: | |
image: mcr.microsoft.com/mssql/server:2022-latest | |
container_name: mssql | |
ports: | |
- "1433:1433" | |
networks: |
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.Diagnostics.CodeAnalysis; | |
using MediatR; | |
using static StatusCodes; | |
// sample usages | |
app.MapCommand<RegisterCustomerDto, RegisterCustomer.Command>("customers", dto => new(dto.Name, dto.Email)); | |
app.MapQuery<GetCustomerDetailDto, GetCustomerDetail.Query>("customers/{CustomerId:int}", dto => new(dto.CustomerId)); | |
public class RegisterCustomerDto | |
{ |
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 abstract record Result | |
{ | |
#region Helper methods | |
public static Success Ok() => new(); | |
public static Success.WithValue<T> Ok<T>(T value) => new(value); | |
public static Failure Fail(string reason) => new(Codes.Unprocessable, reason); | |
public static Failure Error(Exception exception) => new(Codes.Unknown, exception.Message); | |
public static Failure NotFound(string entity) => new(Codes.NotFound, $"{entity} is not found."); | |
public static Failure.Invalid Reject(IDictionary<string, string[]> errors) => new(errors); |
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.IdentityModel.Tokens.Jwt; | |
using System.Security.Claims; | |
using System.Text.Json; | |
using System.Text.Json.Serialization; | |
using Microsoft.Extensions.Caching.Distributed; | |
using Microsoft.IdentityModel.Tokens; | |
/// <summary> | |
/// Reject JWT token containing blacklisted JTI. The JTI is registered into cache provider to be blacklisted, |
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
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base | |
WORKDIR /app | |
EXPOSE 80 | |
EXPOSE 443 | |
ENV ASPNETCORE_URLS "https://+,http://+" | |
ENV ASPNETCORE_HTTPS_PORT 443 | |
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build | |
ENV NODE_VERSION 18.x |
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
# | |
# OpenSSL example configuration file. | |
# This is mostly being used for generation of certificate requests. | |
# | |
# Note that you can include other files from the main configuration | |
# file using the .include directive. | |
#.include filename | |
# This definition stops the following lines choking if HOME isn't |
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
function ConvertTo-Mockaco { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)] | |
[object] | |
$Har, | |
# Output path to Mockaco Mocks folder | |
[Parameter(Mandatory=$false)] | |
[string] |
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 NUnit.Framework; | |
using System; | |
using System.Collections.Generic; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace UnitTests | |
{ | |
[TestFixture] | |
class GivenSemaphoreSlim |
NewerOlder