public void ItInitializesControllerQuickly() { var type = typeof(MyController); var method = type.GetMethod("MyStatement"); var refHandler = (ReflectionStatementDefinition.ReflectionLinkedStatement) new ReflectionStatementDefinition(method, type) .Link("MyStatement"); var context = new InvokationContext() { Scope = "The Scope", Context = new ContextBundle(), Attachments = new ContextBundle(), }; const int iterations = 1000000; var stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < iterations; ++i) { refHandler.InitializeController(refHandler.CreateController(), context); } stopwatch.Stop(); Console.WriteLine("Elapsed: " + stopwatch.ElapsedMilliseconds); Console.WriteLine("Per initialization: " + ((double)stopwatch.ElapsedMilliseconds) / iterations); Assert.Less(stopwatch.ElapsedMilliseconds, 500); }
/// <summary> /// Initializers the specified controller. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="controller">The controller.</param> /// <param name="context">The context.</param> protected void Initializer <T>(StatementController <T> controller, InvokationContext context) { controller.Attachments = context.Attachments; controller.Context = context.Context; controller.Scope = (T)context.Scope; controller.Tracer = context.Tracer; }
public override bool Execute(InvokationContext context) { var controller = new UserController(); Initializer(controller, context); return(controller.HasAccount(context.Proceed)); }
/// <summary> /// Executes the specified context. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public override bool Execute(InvokationContext context) { var controller = new TransactionController(); Initializer(controller, context); return(controller.TimestampBeforeYearsAgo(Years)); }
/// <summary> /// Executes the specified context. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public override bool Execute(InvokationContext context) { var controller = new UserController(); Initializer(controller, context); return(controller.IsActive()); }
public override bool Execute(InvokationContext context) { return(new AccountController() { Scope = (Account)context.Scope, Attachments = context.Attachments, Context = context.Context }.HasTransaction(context.Proceed)); }
public override bool Execute(InvokationContext context) { return(new UserController() { Scope = (User)context.Scope, Attachments = context.Attachments, Context = context.Context }.IsActive()); }
public override bool Execute(InvokationContext context) { return(new UserController() { Scope = (User)context.Scope, Attachments = context.Attachments, Context = context.Context }.HasAccount(context.Proceed)); }
public override bool Execute(InvokationContext context) { var value = int.Parse(context.Match.Groups[1].Captures[0].Value); return(new TransactionController { Scope = (Transaction)context.Scope, Attachments = context.Attachments, Context = context.Context }.TimestampBeforeYearsAgo(value)); }
public object Evaluate(InvokationContext context) { if (context.MethodName == "Dispose") { Dispose(); return(null); } return(InvokeProxy(context.MethodName, context.Parameters)); }
public object Evaluate(InvokationContext context) { this.context = context; object retValue = null; if (context.ReturnType.IsValueType) { retValue = Activator.CreateInstance(context.ReturnType); } return(retValue); }
/// <summary> /// Executes the specified context. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public abstract bool Execute(InvokationContext context);
/// <summary> /// Executes the specified context. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public bool Execute(InvokationContext context) { return(predicate((int)context.Scope)); }
/// <summary> /// Executes the specified context. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public bool Execute(InvokationContext context) { return(((IEnumerable <F>)context.Scope).Any(x => context.Proceed(x))); }
public void Count(InvokationContext context, IStatementDefinition definition) { _counts.Add(Tuple.Create(context, definition)); }
public void Count(InvokationContext context, IStatementDefinition definition) { }