예제 #1
0
파일: Program.cs 프로젝트: doruz/CSharp
        static void Main(string[] args)
        {
            //TestExpressions();

            Instrumentation.Time("Validate Customer", TestCustomerValidation);
            Instrumentation.Time("Validate Customer", DoSomeExpensiveOperation);

            WriteLine();
        }
예제 #2
0
 public DbLogger(ConnectionString connString, ILogger log)
 {
     //Connect = f => ConnectionHelper.Connect(connString, f);
     this.Connect = new Middleware <SqlConnection>(f => { return(ConnectionHelper.Connect <dynamic>(connString, f)); });
     this.Time    = new Func <String, Middleware <Unit> >(op =>
     {
         return(new Middleware <Unit>(f => Instrumentation.Time(log, op, f.ToNullary())));
     });
     this.Trace = op => f => Instrumentation.Trace(log, op, f.ToNullary());
 }
예제 #3
0
        static void _main()
        {
            // call the overload that takes a Func<T>
            var contents = Instrumentation.Time("reading from file.txt"
                                                , () => File.ReadAllText("file.txt"));

            // explicitly call with Func<Unit>
            Instrumentation.Time("reading from file.txt", () =>
            {
                File.AppendAllText("file.txt", "New content!", Encoding.UTF8);
                return(Unit());
            });

            // call the overload that takes an Action
            Instrumentation.Time("reading from file.txt"
                                 , () => File.AppendAllText("file.txt", "New content!", Encoding.UTF8));
        }
예제 #4
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());
 }
예제 #5
0
 public void Log(LogMessage message)
 => Instrumentation.Time("CreateLog"
                         , () => ConnectionHelper.Connect(connString
                                                          , c => c.Execute("sp_create_log"
                                                                           , message, commandType: CommandType.StoredProcedure)));