Ejemplo n.º 1
0
        /// <summary>
        /// 获得网关的参数值。没有参数值时返回空字符串,Get方式的值均为未解码。
        /// </summary>
        /// <param name="gatewayParameterName">网关的参数名称</param>
        /// <param name="gatewayParameterRequestMethod">网关的数据的请求方法的类型</param>
        public string GetGatewayParameterValue(string gatewayParameterName, GatewayParameterRequestMethod gatewayParameterRequestMethod)
        {
            GatewayParameter parameter = GatewayParameterData.SingleOrDefault(p => string.Compare(p.Name, gatewayParameterName) == 0 &&
                                                                              (p.RequestMethod & gatewayParameterRequestMethod) == p.RequestMethod);

            if (parameter != null)
            {
                return(parameter.Value);
            }

            return(string.Empty);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 设置网关的数据
        /// </summary>
        /// <param name="gatewayParameterName">网关的参数名称</param>
        /// <param name="gatewayParameterValue">网关的参数值</param>
        /// <param name="gatewayParameterRequestMethod">网关的参数的请求方法的类型</param>
        /// <remarks>
        /// 当设置的参数存在时,如果参数的值不一致则修改为新的参数值。
        /// </remarks>
        public void SetGatewayParameterValue(string gatewayParameterName, string gatewayParameterValue, GatewayParameterRequestMethod gatewayParameterRequestMethod)
        {
            GatewayParameter existsParam = GatewayParameterData.SingleOrDefault(p => string.Compare(p.Name, gatewayParameterName) == 0);

            if (existsParam == null)
            {
                GatewayParameter param = new GatewayParameter(gatewayParameterName, gatewayParameterValue, gatewayParameterRequestMethod);
                GatewayParameterData.Add(param);
            }
            else
            {
                if (string.Compare(existsParam.Value, gatewayParameterValue) == 0)
                {
                    existsParam.RequestMethod = existsParam.RequestMethod | gatewayParameterRequestMethod;
                }
                else
                {
                    existsParam.RequestMethod = gatewayParameterRequestMethod;
                    existsParam.Value         = gatewayParameterValue;
                }
            }
        }