public void Test() { var b = Boilerplate.New(); b .BeginContract() .Handles <ArgumentException>(ex => { }).WithRetryOf(3, 1000, BackoffStrategy.Exponential) .EndContract() .Do(_ => { throw new ArgumentException(); }); //IMethod method; //ILocalVariable first = method.DefineLocalVariable<int>(); //ILocalVariable second = method.DefineLocalVariable(typeof(int)); //var writtenMethod = // method.Body // .If(first.Equals(second)).Then // .AssignStackValue.To(first) // .Do(first.Call(KnownMetadata.Methods.Object_ToString, second)) // .AssignStackValue.To(second) // .End // .Else // .If(method.Parameter(1).Equals(first)).Then // .End // .NoElse // .End // .End; var boilerplate = Boilerplate.New(visibility: Visibility.Debug); object instance = "Hello"; //boilerplate.BeginContract().RequireValidInstanceOf(new Number { Text = "b" }).EndContract().Do(x => { }); //boilerplate.Use(instance).IfTypeIsAnyOf<int, string, long, object>().DoFirstMatched( // num => { }, // text => { }, // num2 => { }, // obj => { }); // NewMethod(boilerplate, instance); Atomic <object> atom = Atomic <object> .New(instance); Atomic <int> atomInt = Atomic <int> .New(5); boilerplate .BeginContract() //.Handles<Exception, int>(ex => { return 0; }) //.Restrict.Threads.ToMaxOf(1) //.Restrict.Threads.ToMaxOf(5) .Restrict.Threads.ByWaitingFor(new ManualResetEvent(false), 5000) //.Restrict.Threads.ByTransaction // .Of(atom) // .And(atomInt) // .OrderedBy.Default .EndContract() .Do(_ => { object obj = atom; int value = atomInt; atom.Value = obj; atomInt.Value = value; }); int variable = 5; var atomic = boilerplate.Use(variable).AsAtomic(); int o = atomic; var timings = boilerplate .BeginContract() .Handles <Exception>(ex => { }) .IsTimedUnder(Visibility.Debug) .EndContract() .Do(_ => Go()) .Do(_ => Go()) .CallTimings; foreach (var timing in timings) { Console.WriteLine(timing.TotalMilliseconds); } var verifier = new TranslationVerifier <From>(); var results = verifier.VerifyWithTargetOf <To>(); foreach (var result in results) { Debug.WriteLine(result); } var boilerplate2 = Boilerplate.New(visibility: Visibility.Debug); var timings2 = boilerplate2 .BeginContract() .IsTimedUnder(Visibility.Debug) .EndContract() .Do(_ => Go()) .Do(_ => Go()) .Do(_ => Go()) .CallTimings; foreach (var timing in timings) { Console.WriteLine(timing.TotalMilliseconds); } //var provider = new AdoNetConnectionProvider("FluentBoilerplate", DataSource.SQL); //var access = new TypeAccessProvider(provider); //var boilerplate = Boilerplate.New(accessProvider: access); //boilerplate.Open<IAdoNetConnection>().AndDo((_, connection) => // { // var parameter = connection.CreateParameter("count", 5); // var result = connection.ExecuteStoredProcedure("GetPeople", new Interpreter(), parameter); // foreach (var person in result) // Console.WriteLine(person.Name + " " + person.Description); // }); //var boilerplate = Boilerplate.New(accessProvider: new TypeAccessProvider(TypeAccessProvider.w)) //var me = Identity.CurrentWindowsUser; //var context = Boilerplate.New(me); //context.BeginContract() // .MustNotHaveRoles(ActiveDirectoryGroup.Administrators) // .EndContract() // .Do(c => // { // Console.WriteLine("Did not have admin role"); // }); //var stopwatch = new Stopwatch(); //stopwatch.Start(); //Go(); //stopwatch.Stop(); //Debug.WriteLine(stopwatch.ElapsedMilliseconds); //stopwatch.Reset(); //stopwatch.Start(); //Go(); //stopwatch.Stop(); //Debug.WriteLine(stopwatch.ElapsedMilliseconds); }