-
-
Save schotime/1113267 to your computer and use it in GitHub Desktop.
ValidationBehavior<T>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ValidationBehavior<T> : BasicBehavior where T : class | |
{ | |
IFubuRequest request; | |
IChainResolver chain; | |
IPartialFactory _factory; | |
public ValidationBehavior(IFubuRequest request, IChainResolver chain, IPartialFactory factory) : base(PartialBehavior.Executes) | |
{ | |
this.request = request; | |
this.chain = chain; | |
this._factory = factory; | |
} | |
protected override DoNext performInvoke() | |
{ | |
var model = request.Get<T>(); | |
var achain = chain.FindUniqueByInputType(typeof(T)); | |
var getchain = chain.Find(achain.FirstCall().HandlerType, achain.FirstCall().HandlerType.GetMethod("Get")); | |
var input = Activator.CreateInstance(getchain.FirstCall().InputType()); | |
var errorType = input as ErrorModel; | |
errorType.Error = "Error Bitch"; | |
request.Set(input); | |
factory.BuildPartial(getchain.FirstCall()).InvokePartial(); | |
return DoNext.Stop; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment