static ExplicitArguments CreateActivatorArguments(QueryMiddleware <TArgs, TResult> next, object[] args) { var expArgs = new ExplicitArguments(); expArgs.Set(next); foreach (var arg in args) { expArgs.Set(arg.GetType(), arg); } return(expArgs); }
/// <summary> /// 创建查询链 /// </summary> public void BuildChain() { headMiddleware = null; var reversedParams = Enumerable.Reverse(middlewareParams); QueryMiddleware <TArgs, TResult> lastMiddleware = null; foreach (var param in reversedParams) { var expArgs = CreateActivatorArguments(lastMiddleware, param.Item2); var middleware = (QueryMiddleware <TArgs, TResult>)ServiceLocator.Default.IoC.GetInstance(param.Item1, expArgs); lastMiddleware = middleware; } headMiddleware = lastMiddleware; chainUpdated = true; }
public QueryMiddleware(QueryMiddleware <TArgs, TResult> next) { Next = next; }