/// <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); }
/// <summary> /// 获得网关的参数值。没有参数值时返回空字符串,Get方式的值均为未解码。 /// </summary> /// <param name="gatewayParameterName">网关的参数名称</param> /// <param name="httpMethod">网关的数据的请求方法的类型</param> public string GetGatewayParameterValue(string gatewayParameterName, HttpMethod httpMethod) { if (gatewayParameterList.ContainsKey(gatewayParameterName)) { GatewayParameter gatewayParameter = gatewayParameterList[gatewayParameterName]; if (httpMethod == HttpMethod.None || httpMethod == gatewayParameter.HttpMethod) { return(gatewayParameter.Value); } } return(string.Empty); }
/// <summary> /// 获得网关的参数值,参数不存在时返回空字符串。 /// </summary> /// <typeparam name="T">返回的数据类型</typeparam> /// <param name="gatewayParameterName">网关参数的名称</param> /// <param name="httpMethod">网关数据请求方法的类型</param> public T GetGatewayParameterValue <T>(string gatewayParameterName, HttpMethod httpMethod) { string gatewayParameterValue = string.Empty; if (_gatewayParameterList.ContainsKey(gatewayParameterName)) { GatewayParameter gatewayParameter = _gatewayParameterList[gatewayParameterName]; if (httpMethod == HttpMethod.None || httpMethod == gatewayParameter.HttpMethod) { gatewayParameterValue = gatewayParameter.Value; } } return((T)Convert.ChangeType(gatewayParameterValue, typeof(T))); }
/// <summary> /// 设置网关的数据 /// </summary> /// <param name="gatewayParameterName">网关的参数名称</param> /// <param name="gatewayParameterValue">网关的参数值</param> /// <param name="gatewayParameterRequestMethod">网关的参数的请求方法的类型</param> 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 != gatewayParameterRequestMethod) { existsParam.RequestMethod = gatewayParameterRequestMethod; existsParam.Value = gatewayParameterValue; } } }
/// <summary> /// 设置网关的数据 /// </summary> /// <param name="gatewayParameterName">网关的参数名称</param> /// <param name="gatewayParameterValue">网关的参数值</param> /// <param name="httpMethod">网关的参数的请求方法的类型</param> public void SetGatewayParameterValue(string gatewayParameterName, string gatewayParameterValue, HttpMethod httpMethod) { if (gatewayParameterList.ContainsKey(gatewayParameterName)) { GatewayParameter gatewayParameter = gatewayParameterList[gatewayParameterName]; if (string.Compare(gatewayParameter.Value, gatewayParameterValue) != 0 || gatewayParameter.HttpMethod != httpMethod) { gatewayParameter.HttpMethod = httpMethod; gatewayParameter.Value = gatewayParameterValue; } } else { GatewayParameter gatewayParameter = new GatewayParameter(gatewayParameterName, gatewayParameterValue, httpMethod); gatewayParameterList.Add(gatewayParameterName, gatewayParameter); } }
/// <summary> /// 设置网关的数据 /// </summary> /// <param name="gatewayParameterName">网关的参数名称</param> /// <param name="gatewayParameterValue">网关的参数值</param> /// <param name="gatewayParameterType">网关的参数的类型</param> /// <remarks> /// 设置的参数存在时,如果参数的值不一致则保存新的参数值。 /// </remarks> public void SetGatewayParameterValue(string gatewayParameterName, string gatewayParameterValue, GatewayParameterType gatewayParameterType) { GatewayParameter existsParam = GatewayParameterData.SingleOrDefault(p => string.Compare(p.Name, gatewayParameterName) == 0); if (existsParam == null) { GatewayParameter param = new GatewayParameter(gatewayParameterName, gatewayParameterValue, gatewayParameterType); GatewayParameterData.Add(param); } else { if (string.Compare(existsParam.Value, gatewayParameterValue) == 0) { existsParam.Type = existsParam.Type | gatewayParameterType; } else { existsParam.Type = gatewayParameterType; existsParam.Value = gatewayParameterValue; } } }
/// <summary> /// 设置网关的数据 /// </summary> /// <param name="gatewayParameterList">保存网关参数的集合</param> /// <param name="gatewayParameterName">网关的参数名称</param> /// <param name="gatewayParameterValue">网关的参数值</param> /// <param name="gatewayParameterRequestMethod">网关的参数的请求方式的类型</param> private static void SetGatewayParameterValue(List <GatewayParameter> gatewayParameterList, string gatewayParameterName, string gatewayParameterValue, GatewayParameterRequestMethod gatewayParameterRequestMethod) { GatewayParameter existsParam = gatewayParameterList.SingleOrDefault(p => string.Compare(p.Name, gatewayParameterName) == 0); if (existsParam == null) { GatewayParameter param = new GatewayParameter(gatewayParameterName, gatewayParameterValue, gatewayParameterRequestMethod); gatewayParameterList.Add(param); } else { if (string.Compare(existsParam.Value, gatewayParameterValue) == 0) { existsParam.RequestMethod = existsParam.RequestMethod | gatewayParameterRequestMethod; } else { existsParam.RequestMethod = gatewayParameterRequestMethod; existsParam.Value = gatewayParameterValue; } } }
/// <summary> /// �������ص����� /// </summary> /// <param name="gatewayParameterName">���صIJ�������</param> /// <param name="gatewayParameterValue">���صIJ���ֵ</param> /// <param name="gatewayParameterRequestMethod">���صIJ���������������</param> /// <remarks> /// �����õIJ�������ʱ�����������ֵ��һ������Ϊ�µIJ���ֵ�� /// </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; } } }