private Type GetViewType(ComponentMethodAttribute componentMethodAttribute) { if (componentMethodAttribute == null) { throw new ViewNotFoundException("Please set up attributes correctly."); } return(this.GetViewType(componentMethodAttribute.ViewName)); }
private MethodInfo GetMethodToResponse(Type viewType, ComponentMethodAttribute componentMethodAttribute) { if (componentMethodAttribute == null) { throw new ResponseNotFoundException("Please set up correctly Response Attribute."); } MethodInfo responseMethod = viewType.GetMethod(componentMethodAttribute.ResponseName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); if (responseMethod == null) { throw new ResponseNotFoundException("Response: " + componentMethodAttribute.ResponseName + " not found in: " + viewType.ToString()); } else { logger.Debug("Finded response to execute: " + responseMethod.ToString() + " in: " + viewType.ToString()); } return(responseMethod); }
private Type GetViewType(ComponentMethodAttribute componentMethodAttribute) { if (componentMethodAttribute == null) throw new ViewNotFoundException ("Please set up attributes correctly."); return this.GetViewType (componentMethodAttribute.ViewName); }
private MethodInfo GetMethodToResponse(Type viewType, ComponentMethodAttribute componentMethodAttribute) { if (componentMethodAttribute == null) { throw new ResponseNotFoundException ("Please set up correctly Response Attribute."); } MethodInfo responseMethod = viewType.GetMethod (componentMethodAttribute.ResponseName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public) ; if (responseMethod == null) throw new ResponseNotFoundException ("Response: " + componentMethodAttribute.ResponseName + " not found in: " + viewType.ToString ()); else logger.Debug ("Finded response to execute: " + responseMethod.ToString () + " in: " + viewType.ToString ()); return responseMethod; }
/*Executor commander !*/ public ResponseMethodDTO Execute(string methodName, object[] parameters, bool redirect, IViewHandler viewHandler, bool block) { /*Existen cosas que siempre deben de buscarse*/ MethodInfo methodToExecute = this.GetMethodToExecute(methodName, parameters); ComponentMethodAttribute componentMethodAttribute = this.GetComponentAttributes(methodToExecute); /*Primero discernimos si es bloqueante o no lo es*/ if (block) { //Operaciones que son bloqueantes if (redirect) { MethodInfo methodToResponse; Type viewType; if (viewHandler == null) { //FIX: Aún se podria mejorar esta invocación. viewType = this.GetViewType(componentMethodAttribute); methodToResponse = this.GetMethodToResponse(viewType, componentMethodAttribute); return(ExecuteRedirectNewView(methodToExecute, parameters, viewType, methodToResponse)); } else { //Redirigimos a la que nos pide viewType = viewHandler.GetType(); methodToResponse = this.GetMethodToResponse(viewType, componentMethodAttribute); return(ExecuteRedirectView(methodToExecute, parameters, viewHandler, methodToResponse)); } } else { //No necesitamos información sobre la vista, ni el response. //No se va a ejecutar. return(ExecuteNoRedirect(methodToExecute, parameters)); } } else { ComponentActionDispatcher componentActionDispatcher; //Operaciones bloqueantes, envolver en un hilo if (redirect) { MethodInfo methodToResponse; Type viewType; if (viewHandler == null) { //Exception handling ¿¿ viewType = this.GetViewType(componentMethodAttribute); methodToResponse = this.GetMethodToResponse(viewType, componentMethodAttribute); componentActionDispatcher = new ComponentActionDispatcher(this, methodToExecute, parameters, viewType, methodToResponse); try { componentActionDispatcher.Do(); } catch (TargetInvocationException exception) { this.MapException(exception); } return(componentActionDispatcher.ResponseMethodDTO); } else { viewType = viewHandler.GetType(); methodToResponse = this.GetMethodToResponse(viewType, componentMethodAttribute); componentActionDispatcher = new ComponentActionDispatcher(this, methodToExecute, parameters, viewHandler, methodToResponse); try { componentActionDispatcher.Do(); } catch (TargetInvocationException exception) { this.MapException(exception); } return(componentActionDispatcher.ResponseMethodDTO); } } else { componentActionDispatcher = new ComponentActionDispatcher(this, methodToExecute, parameters); try { componentActionDispatcher.Do(); } catch (TargetInvocationException exception) { this.MapException(exception); } return(componentActionDispatcher.ResponseMethodDTO); } } //return null; }