---
title: Order example
---
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
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 UrlServiceResolverHandler : DelegatingHandler | |
{ | |
readonly ILogger<UrlServiceResolverHandler> logger; | |
public UrlServiceResolverHandler(ILogger<UrlServiceResolverHandler> logger) | |
{ | |
this.logger = logger; | |
InnerHandler = new HttpClientHandler(); | |
} |
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.IO.Compression; | |
using System.Text; | |
interface ICompressor | |
{ | |
public const string Header = "[z]"; | |
Task<string> Compress(string text); | |
Task<string> Decompress(string text); | |
} |
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.Globalization; | |
using System.Text.Json; | |
using System.Text.Json.Serialization; | |
namespace Heptapod.Models.Values; | |
[JsonConverter(typeof(UtcJsonConverter))] | |
public readonly struct DateUtc | |
{ | |
public DateUtc(DateTime dateTime) => DateTime = dateTime.ToUniversalTime(); |
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<TOk, TError> | |
{ | |
public sealed record Ok(TOk Value) : Result<TOk, TError> | |
{ | |
public override TOk Default(TOk defaultValueIfError) => Value; | |
public override T Match<T>(Func<TOk, T> ok, Func<TError, T> error) => ok(Value); | |
public override Result<TMap, TError> Select<TMap>(Func<TOk, TMap> map) => map(Value); | |
public override Result<TMap, TError> Bind<TMap>(Func<TOk, Result<TMap, TError>> bind) => bind(Value); | |
public override bool IsError => false; | |
} |
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.ComponentModel; | |
public static string GetDescription<T>(this T option) where T : Enum => option | |
.GetType().GetMember(option.ToString()) | |
.SelectMany(p => p.GetCustomAttributes(typeof(DescriptionAttribute), true)) | |
.FirstOrDefault() is DescriptionAttribute attr | |
? attr.Description | |
: option.ToString(); |
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
[<AutoOpen>] | |
module MinimalExtensions | |
open System | |
open Microsoft.AspNetCore.Builder | |
open Microsoft.AspNetCore.Routing | |
type IEndpointRouteBuilder with | |
static member ParseArityOneFuncToDelegate(func: Func<'a, 'b>) : Delegate = | |
match box func with |
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
type TupleToObject<T extends any[]> = { [K in keyof T as Exclude<K, keyof any[]>]: T[K] } | |
type MapTuples<T extends any[], N extends Record<keyof TupleToObject<T>, PropertyKey>> = | |
{ [K in keyof TupleToObject<T> as N[K]]: T[K] } | |
type IsNever<T> = [T] extends [never] ? true : false | |
type Numbers = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] | |
type IncMap = MapTuples<Tail<Numbers>, Numbers> | |
type Inc<T extends number> = T extends keyof IncMap ? IncMap[T] : never | |
export type Reverse<T extends any[], R extends any[] = []> = { | |
return: R | |
next: Reverse<Tail<T>, Cons<Head<T>, R>> |
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
export type AllChars = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] | |
export type ValidChar = AllChars[number] | |
type TupleToObject<T extends any[]> = { [K in keyof T as Exclude<K, keyof any[]>]: T[K] } | |
type MapTuples< | |
T extends any[], | |
N extends Record<keyof TupleToObject<T>, PropertyKey>> = | |
{ [K in keyof TupleToObject<T> as N[K]]: T[K] } | |
type IncMap = MapTuples<Tail<AllChars>, AllChars> |
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
type IncMap = { 0: 1; 1: 2; 2: 3; 3: 4; 4: 5; 5: 6; 6: 7; 7: 8; 8: 9; 9: 10; | |
10:11;11:12;12:13;13:14;14:15;15:16;16:17;17:18;18:19;19:20; | |
20:21;21:22;22:23;23:24;24:25;25:26 } | |
type Inc<T extends number> = T extends keyof IncMap ? IncMap[T] : never | |
type Head<T extends any[]> = T extends [any, ...any[]] ? T['0'] : never | |
type Tail<T extends any[]> = ((...t: T) => never) extends (h: any, ...rest: infer R) => never ? R : never | |
type Cons<V,T extends any[]> = ((h: V, ...t: T) => void) extends (...t: infer R) => void ? R : never | |
type IsEqual<A, B> = A extends B ? (B extends A ? true : false) : false | |
type IsNever<T> = [T] extends [never] ? true : false |