This file contains hidden or 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 Option<ReservationViewModel> AddItemToReservation(string id, string itemId) | |
{ | |
var reservationOptinal = _restaurant.GetReservation(id); | |
var itemOptional = _inventory.GetItem(itemId); | |
return reservationOptinal.Intersect(itemOptional) | |
.Select(AddItemFunc) | |
.Select(reservation => (reservation, _ClientsManger.GetUser(reservation.UserId))) | |
.Select(MapToViewModel); |
This file contains hidden or 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 OptionExtensions | |
{ | |
public static Option<(TOuterA, TOuterB, TInner)> Intersect<TOuterA, TOuterB, TInner>(this Option<(TOuterA, TOuterB)> outer, Option<TInner> inner) | |
{ | |
return outer.HasValue && inner.HasValue | |
? outer.Select(outer1 => (outer1.Item1,outer1.Item2, inner.ValueOrFailure())) | |
: Option.None<(TOuterA, TOuterB, TInner)>(); | |
} | |
public static Option<(TOuter,TInner)> Intersect<TOuter, TInner>(this Option<TOuter> outer,Option<TInner> inner) | |
{ |
This file contains hidden or 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 partial FunctionaObject2 where T: class, ICloneable, new() | |
{ | |
public static Func<FunctionalObject<T>, P> NewGetLens<P>(Func<T, P> func) | |
{ | |
return (o => func.Invoke(o.GetValue())); | |
} | |
public static Func<FunctionalObject<T>, FunctionalObject<T>> NewSetLens(Action<T> func) | |
{ | |
return o => o.With(func); |
This file contains hidden or 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 Model:ICloneable | |
{ | |
public string Item { get; set; } | |
public int Price { get; set; } | |
public object Clone() | |
{ | |
return new Model() | |
{ | |
Price = this.Price, |
This file contains hidden or 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 partial FunctionaObject2 where T: class, ICloneable, new() | |
{ | |
public static Func<FunctionalObject<T>, P> NewGetLens<P>(Func<T, P> func) | |
{ | |
return (o => func.Invoke(o.GetValue())); | |
} | |
public static Func<FunctionalObject<T>, FunctionalObject<T>> NewSetLens(Action<T> func) | |
{ | |
return o => o.With(func); |
This file contains hidden or 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 GeneratorEnumerator<T> : IEnumerator<T> | |
{ | |
private readonly Func<int,T> _generatorFunc; | |
private int _index; | |
private T _current; | |
public GeneratorEnumerator(Func<int, T> generatorFunc) | |
{ | |
_generatorFunc = generatorFunc; | |
} |
This file contains hidden or 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 Generator<T> : IEnumerable<T> | |
{ | |
private GeneratorEnumerator<T> _generatorEnumerator; | |
public Generator(Func<int, T> generatorFunc) | |
{ | |
_generatorEnumerator = new GeneratorEnumerator<T>(generatorFunc); | |
} | |
public IEnumerator<T> GetEnumerator() |
This file contains hidden or 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 Function1 | |
{ | |
[FunctionName("kofi")] | |
public static async Task<IActionResult> Run( | |
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] | |
HttpRequest req, | |
ILogger log) | |
{ |
This file contains hidden or 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 TaskAsyncEnumerable<T> : IAsyncEnumerable<T> | |
{ | |
private Func<Task<Option<T>>> _asyncTask; | |
private TimeSpan timeSpan; | |
public TaskAsyncEnumerable(Func<Task<Option<T>>> asyncTask) | |
{ | |
_asyncTask = asyncTask; | |
} |
This file contains hidden or 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 IFileSystem | |
{ | |
File CreateFile(string filename); | |
void DeleteFile(string filename); | |
File GetFile(string filename); | |
public File GetOrCreateFile(string filename) | |
{ | |
var file = GetFile(filename); |