public static UriDescriptor Parse(string uri, Exchange exchange = null) { var parts = new UriDescriptor(); if (exchange != null) { uri = SimpleExpression.ResolveSpecifiedUriPart(uri, exchange); } if (string.IsNullOrEmpty(uri)) { throw new SynapseException("uri data error: cannot be empty"); } var mainParts = uri.Split(new[] { '?' }, 2); var uriPrimaryParts = mainParts[0].Split(new[] { ':' }, 2); parts.ComponentName = uriPrimaryParts.Length >= 1 ? uriPrimaryParts[0] : ""; parts.ComponentPath = uriPrimaryParts.Length >= 2 ? uriPrimaryParts[1] : ""; parts.ComponentQueryPath = mainParts.Length > 1 ? mainParts[1] : ""; parts.FullUri = uri; return(parts); }
/// <summary> /// Check If RouteName Override Required /// </summary> private void CheckIfRouteNameOverrideRequired() { try { var stepName = _currentStepXml.Name.ToString(); switch (stepName) { case TagConstant.FromTag: var val = _currentStepXml.Attribute(TagConstant.Uri).Value; var desc = UriDescriptor.Parse(val); if (desc.ComponentName == TagConstant.Direct) { Route.RouteId = desc.ComponentPath; } if (desc.ComponentName == TagConstant.Seda) { Route.RouteId = desc.ComponentPath; } break; } } catch (Exception exception) { var msg = exception.Message; } }
/// <summary> /// Handle To Method /// </summary> /// <param name="leafDescriptor"></param> /// <param name="exchange"></param> /// <param name="route"></param> public static void HandleTo(UriDescriptor leafDescriptor, Exchange exchange, Route route) { try { EndpointBase endPoint; if (SynapseContext.EnPointCollection.TryGetValue(leafDescriptor.FullUri, out endPoint)) { } else { var execAssembly = Assembly.GetExecutingAssembly(); var types = execAssembly.GetTypes(); foreach (var namespaceToCheck in PermissibleNamespaces) { var typeData = types.FirstOrDefault(c => c.FullName.Equals(string.Format("{0}.{1}.{2}", namespaceToCheck, leafDescriptor.ComponentName, leafDescriptor.ComponentName), StringComparison.InvariantCultureIgnoreCase) || c.FullName.Equals(string.Format("{0}.{1}.{2}EndPoint", namespaceToCheck, leafDescriptor.ComponentName, leafDescriptor.ComponentName), StringComparison.InvariantCultureIgnoreCase)); if (typeData == null) { continue; } endPoint = (EndpointBase)Activator.CreateInstance(typeData, leafDescriptor.FullUri, route); SynapseContext.EnPointCollection.TryAdd(leafDescriptor.FullUri, endPoint); break; } } if (endPoint != null) { endPoint.Send(exchange, leafDescriptor); } else { throw new SynapseException("[MissingEndPoint] - " + leafDescriptor.ComponentName); } } catch (AggregateException exception) { throw new SynapseException("[EndPointIssues] - " + leafDescriptor.ComponentName, exception); } catch (Exception exception) { throw new SynapseException("[EndPointIssues] - " + leafDescriptor.ComponentName, exception); } }
protected ProcessorBase(UriDescriptor uriInformation, Route route) { UriInformation = uriInformation; Route = route; }