public Task <object> FindObjRef(string n, string i, CancellationToken cancel) { if (RRContext == null) { throw new ServiceException("Reference has been released"); } return(RRContext.FindObjRef(RRServicePath + "." + n + "[" + RRUriExtensions.EscapeDataString(i.ToString()).Replace(".", "%2e") + "]", null, cancel)); }
public static ParseConnectionUrlResult ParseConnectionUrl(string url) { var rr1 = new Regex("^([^:\\s]+)://(?:((?:\\[[A-Fa-f0-9\\:]+(?:\\%\\w*)?\\])|(?:[^\\[\\]\\:/\\?\\s]+))(?::([^:/\\?\\s]+))?|/)(?:/([^\\?\\s]*))?\\??([^\\s]*)$"); var u1 = rr1.Match(url); if (!u1.Success) { throw new ConnectionException("Invalid connection URL"); } if (!u1.Groups[1].Success) { throw new ConnectionException("Invalid connection URL"); } var o = new ParseConnectionUrlResult(); o.scheme = u1.Groups[1].Value; o.host = u1.Groups[2].Value; if (u1.Groups[3].Success && u1.Groups[3].Value != "") { o.port = int.Parse(u1.Groups[3].Value); } else { o.port = -1; } if (o.scheme == "tcp") { if (u1.Groups[5].Success && u1.Groups[5].Value != "") { throw new ConnectionException("Invalid connection URL"); } if (!(u1.Groups[4].Success && u1.Groups[4].Value != "")) { throw new ConnectionException("Invalid connection URL"); } var ap = u1.Groups[4].Value.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); if (ap.Length != 2) { throw new ConnectionException("Invalid connection URL"); } string noden = ap[0]; if (noden.Contains("{") || noden.Contains("[")) { o.nodeid = new NodeID(noden); o.nodename = ""; } else { o.nodename = noden; o.nodeid = NodeID.Any; } o.service = ap[1]; o.path = "/"; return(o); } if (o.port == -1) { if (o.scheme == "rr+tcp" || o.scheme == "rrs+tcp") { o.port = 48653; } if (o.scheme == "rr+ws" || o.scheme == "rrs+ws") { o.port = 80; } if (o.scheme == "rr+wss" || o.scheme == "rrs+wss") { o.port = 443; } } o.path = u1.Groups[4].Value; if (o.path == null || o.path == "") { o.path = "/"; } var query_params = new Dictionary <string, string>(); if (!(u1.Groups[5].Success && u1.Groups[5].Value != "")) { throw new ConnectionException("Invalid connection URL"); } var q2 = new List <string>(); foreach (var e in u1.Groups[5].Value.TrimStart(new char[] { '?' }).Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries)) { var q3 = e.Split(new char[] { '=' }); if (q3.Length != 2) { throw new ConnectionException("Invalid Connection URL"); } if (q3[0].Length == 0 || q3[1].Length == 0) { throw new ConnectionException("Invalid Connection URL"); } query_params.Add(q3[0], RRUriExtensions.UnescapeDataString(q3[1])); } if (!query_params.ContainsKey("service")) { throw new ConnectionException("Invalid Connection URL"); } o.service = query_params["service"]; if (String.IsNullOrWhiteSpace(o.service)) { throw new ConnectionException("Invalid Connection URL"); } if (query_params.ContainsKey("nodeid")) { o.nodeid = new NodeID(query_params["nodeid"]); } else { o.nodeid = NodeID.Any; } if (query_params.ContainsKey("nodename")) { o.nodename = query_params["nodename"]; var rr = new Regex("^[a-zA-Z][a-zA-Z0-9_\\.\\-]*$"); if (!rr.Match(o.nodename).Success) { throw new ConnectionException("\"" + o.nodename + "\" is an invalid NodeName"); } } else { o.nodename = ""; } return(o); }