Exemplo n.º 1
0
 public DbLogger(ConnectionString connString, ILogger log)
 {
     Connect = f => ConnectionHelper.Connect(connString, f);
     Time    = op => f => Instrumentation.Time(log, op, f.ToNullary());
     Trace   = op => f => Instrumentation.Trace(log, op, f.ToNullary());
 }
Exemplo n.º 2
0
 public static Middleware <RR> SelectMany <T, R, RR>
     (this Middleware <T> @this, Func <T, Middleware <R> > f, Func <T, R, RR> project)
 => cont => @this(t => f(t)(r => cont(project(t, r))));
Exemplo n.º 3
0
 public static T Run <T>(this Middleware <T> mw) => mw(t => t);
Exemplo n.º 4
0
 public static Middleware <R> SelectMany <T, R>
     (this Middleware <T> mw, Func <T, Middleware <R> > f)
 => cont => mw(t => f(t)(cont));
Exemplo n.º 5
0
 public static Middleware <R> Select <T, R>
     (this Middleware <T> mw, Func <T, R> f)
 => cont => mw(t => cont(f(t)));
Exemplo n.º 6
0
 public static Middleware <R> Bind <T, R>
     (this Middleware <T> mw, Func <T, Middleware <R> > f)
 => SelectMany(mw, f);
Exemplo n.º 7
0
 public static Middleware <R> Map <T, R>
     (this Middleware <T> mw, Func <T, R> f)
 => Select(mw, f);
Exemplo n.º 8
0
        // cand definesc o variabila un delegate Middleware<T> = definesc o metoda care primeste ca parametru un Func<T, dynamic> delegate si corpul executiei ei
        // cand invoc un delegate Middleware<T> = definesc functia care primeste un T si intoarce un dynamic, altfel spus specific parametrii/argumetele lui Middleware<T>,
        // altfel spus instantiez delegat-ul Func<T, dynamic>

        //public static Middleware<R> SelectMany<T, R>
        //   (this Middleware<T> mw, Func<T, Middleware<R>> f)
        //   => cont => mw(t => f(t)(cont));

        public static Middleware <R> SelectMany <T, R>
            (this Middleware <T> mw, Func <T, Middleware <R> > f)
        {
            return(new Middleware <R>(cont => { return (dynamic)mw.Invoke(new Func <T, dynamic>(t => f.Invoke(t).Invoke(cont))); }));
        }