コード例 #1
0
ファイル: Program.cs プロジェクト: zhftxdy/Oxygen-Dapr
 internal static void SetCurrent(OxygenHttpContextWapper httpContextWapper)
 {
     if (currentcontext.Value == null)
     {
         currentcontext.Value = httpContextWapper;
     }
 }
コード例 #2
0
 public static async Task BeforeSendHandler(object param, OxygenHttpContextWapper oxygenHttpContext)
 {
     await new AuthenticationHandler().AuthenticationCheck(HttpContextExt.Current.RoutePath);//授权校验
     //方法前拦截器,入参校验
     if (param != null)
     {
         CustomModelValidator.Valid(param);
     }
     oxygenHttpContext.Headers.Add("AuthIgnore", "true");
     await Task.CompletedTask;
 }
コード例 #3
0
 public static void ContextHandler(OxygenHttpContextWapper oxygenHttpContext)
 {
     HttpContextExt.SetCurrent(oxygenHttpContext);//注入http上下文给本地业务上下文对象
 }
コード例 #4
0
 public static async Task BeforeSendHandler(object param, OxygenHttpContextWapper oxygenHttpContext)
 {
     await Task.CompletedTask;
 }
コード例 #5
0
        /// <summary>
        /// 调用方法前后异常匿名委托
        /// </summary>
        /// <typeparam name="Tin"></typeparam>
        /// <typeparam name="Tout"></typeparam>
        /// <param name="param"></param>
        /// <param name="method"></param>
        /// <returns></returns>
        public static async Task <Tout> UsePipelineHandler <Tobj, Tin, Tout>(ILifetimeScope scope, Tin param, OxygenHttpContextWapper wapper, Func <Tobj, Tin, Task <Tout> > method) where Tin : new() where Tout : class
        {
            try
            {
                Tout result = default;
                if (ContextRegister != null)
                {
                    ContextRegister(wapper);
                }
                if (BeforeFunc != null)
                {
                    await BeforeFunc(param, wapper);
                }
                result = await method(scope.Resolve <Tobj>(), param);

                if (AfterFunc != null)
                {
                    await AfterFunc(result);
                }
                return(result);
            }
            catch (Exception e)
            {
                if (ExceptionFunc != null)
                {
                    return(await ExceptionFunc(e));
                }
            }
            return(default);