private IDictionary <string, string> systemParameters; // 设置所有请求共享的系统级参数 #region DefaultOneNETClient Constructors /// <summary> /// 基于REST的OneNET客户端。 /// </summary> public DefaultOneNETClient(string serverUrl, string appKey) { this.appKey = appKey; this.context = new OneNetContext(); this.context.setContext(OneNetContext.API_ADDRESS, serverUrl); this.webUtils = new WebUtils(); this.OneNETLogger = new DefaultOneNETLogger(); }
/// <summary> /// 组装API URL /// </summary> /// <param name="uri">形如"<scheme>://<API_ADDRESS>/keys"的字符串,其中会依据context中的内容替换<>中的内容</param> /// <param name="context">数值,用于组装URL</param> /// <returns></returns> public static String fmtURI(String uri, OneNetContext context) { var re = new Regex(PATTERN); var matches = re.Matches(uri); foreach (var match in matches) { object val; var m = match.ToString(); var key = m.TrimStart('<').TrimEnd('>'); context.getContext().TryGetValue(key, out val); if (val != null) { uri = uri.Replace(m, val.ToString()); } } return(uri); }
public OneNetContext(OneNetContext context) { this.context.Add(SCHEME, Scheme.HTTP.GetSchemeString()); this.context = this.context.Merge(context.context); parameter = parameter.Merge(context.parameter); }