示例#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));
        }
 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());
 }
 public void Log(LogMessage message)
 => Instrumentation.Time("CreateLog"
                         , () => ConnectionHelper.Connect(connString
                                                          , c => c.Execute("sp_create_log"
                                                                           , message, commandType: CommandType.StoredProcedure)));