Esempio n. 1
0
        /// <summary>
        /// 设置请求上下文的Tags
        /// </summary>
        /// <param name="reqContext">请求上下文</param>
        protected void SetReqContextTags(JsonRpcRequestContext reqContext)
        {
            if (reqContext.Tags == null)
            {
                reqContext = new JsonRpcRequestContext();
            }

            //引用全局事件中的上下文注入函数,从而将其加入到JsonRpcRequestContext.Tags
            if (JsonRpcRequest.Handler != null)
            {
                JsonRpcRequest.Handler(reqContext.Tags);
            }

            //合并当前Invoker Option到JsonRpcRequestContext Tag中
            if (Option != null && Option.ContextValues != null)
            {
                foreach (var key in Option.ContextValues.Keys)
                {
                    reqContext.Tags[key] = Option.ContextValues[key];
                }
            }

            if (Option != null && Option.ForceWriteDB)
            {
                reqContext.Tags["x-rpc-forcewritedb"] = "true";
            }
        }