/// <summary> /// Find the composite http server for the current service name. /// </summary> /// <param name="directories">The list of directories that contain the composite http service.</param> /// <param name="httpServiceExits">Has the http composite server been found.</param> /// <returns>The collection of cloned http composite servers.</returns> public Nequeo.Net.Http.IHttpServerContext[] FindCompositeContext(string[] directories, out bool httpServiceExits) { // Get the current value. List <Nequeo.Net.Http.IHttpServerContext> httpContextServers = new List <Nequeo.Net.Http.IHttpServerContext>(); httpServiceExits = false; // For each message import in the collection. foreach (Lazy <Nequeo.Net.Http.IHttpServerContext, IContentMetadata> item in HttpServerContext) { // Get the current value. Nequeo.Net.Http.IHttpServerContext messageValue = item.Value; // Get the current metadata. IContentMetadata metadata = item.Metadata; // If the metadata name matches the request path. if (HttpServiceExistsInRequest(directories, metadata)) { // The http service has been found. httpServiceExits = true; // Clone the current http server context // and add to the context collection. Nequeo.Net.Http.IHttpServerContext cloneServer = (Nequeo.Net.Http.IHttpServerContext)messageValue.Clone(); httpContextServers.Add(cloneServer); } } // Return the http context. return(httpContextServers.ToArray()); }
/// <summary> /// If there is a match between the current URL service request and the metadata service store. /// </summary> /// <param name="directories">The list of directories that contain the composite http service.</param> /// <param name="metadata">The current service metadata.</param> /// <returns>True if the http service has been found; else false.</returns> public bool HttpServiceExistsInRequest(string[] directories, IContentMetadata metadata) { // Search for the current metadata service name // within the URL directory list requested from // the current client. IEnumerable <string> httpServices = directories.Where(u => u.ToLower() == metadata.Name.ToLower()); // Has a http service been found. if (httpServices != null) { if (httpServices.Count() > 0) { // A http service match has been found. return(true); } } // Return false no http service match found. return(false); }