private void RegisterPipeData(XmlNode configNode) { lock (this.availablePipes) { HttpPipeMeta pipeInfo = new HttpPipeMeta(); pipeInfo.Config = new Dictionary <object, object>(); pipeInfo.PipeName = configNode.Attributes["name"].Value; pipeInfo.Classname = configNode.Attributes["classname"].Value; try { if (configNode.Attributes["assembly"] != null) { pipeInfo.Assembly = configNode.Attributes["assembly"].Value; } } catch { } foreach (XmlNode xmlNd in configNode.ChildNodes) { if (xmlNd.Name.ToLower().Equals("data")) { foreach (XmlNode nd in xmlNd.ChildNodes) { pipeInfo.Config.Add(nd.Name, nd.InnerText); } } } if (String.IsNullOrEmpty(pipeInfo.PipeName) || String.IsNullOrEmpty(pipeInfo.Classname)) { throw new InvalidConfigException(); } if (this.availablePipes.ContainsKey(pipeInfo.PipeName)) { this.availablePipes.Remove(pipeInfo.PipeName); } this.availablePipes.Add(pipeInfo.PipeName, pipeInfo); } }
public HttpPipe GetPipeInstance(String pipeName, HttpPipesChainsFactory httpPipesChainsFactory) { if (!availablePipes.ContainsKey(pipeName)) { throw new HttpPipeNotFoundException(); } HttpPipeMeta mi = availablePipes[pipeName]; Assembly pipeAssembly = null; if (String.IsNullOrEmpty(mi.Assembly) == false) { String location = mi.Assembly; if (File.Exists(location) == false) { location = (Path.GetDirectoryName(Assembly.GetAssembly(typeof(HttpPipesRepository)).Location).Replace("\\", "/") + "/" + location); } if (File.Exists(location)) { pipeAssembly = Assembly.LoadFrom(location); } } if (pipeAssembly == null) { pipeAssembly = Assembly.GetAssembly(typeof(HttpPipesRepository)); } HttpPipe pipe = (HttpPipe)pipeAssembly.CreateInstance(mi.Classname); pipe.Configuration = this.config; pipe.ChainsFactory = httpPipesChainsFactory; pipe.Init(mi.Config); return(pipe); }