public IModulePathNode CreatePath(string path) { if (path == null || path.Length == 0) { return(pathRoot); } string[] splittedPath = path.Split(new char[] { '/' }); IModulePathNode curPath = pathRoot; int i = 0; while (i < splittedPath.Length) { if (splittedPath[i].Length != 0) { IModulePathNode nextPath = (IModulePathNode)curPath.ChildNodes[splittedPath[i]]; if (nextPath == null) { curPath.ChildNodes[splittedPath[i]] = nextPath = new DefaultModulePathNode(splittedPath[i], curPath); } curPath = nextPath; } ++i; } return(curPath); }
/// <summary> /// Adds a module instance. /// </summary> /// <param name="path">the path</param> /// <param name="instance">The IModule to be inserted</param> public void AddModuleInstance(String path, IModule instance) { IModulePathNode node = CreatePath(path); node.Module = instance; moduleList.Add(instance); }
/// <remarks> /// Requestes a specific Module, may return null if this Module is not found. /// </remarks> public IModule GetModule(string path) { IModulePathNode node = ResolvePath(path); if (node != null) { return(node.Module); } else { return(null); } }
/// <summary> /// Shortcut to the method <see cref="Resolve"/> /// </summary> public IModule this[String id] { get { IModulePathNode node = (IModulePathNode)childNodes[id]; if (node != null) { return(node.Module); } else { return(null); } } }
/// <remarks> /// This method initializes the Modules according to the provided key. /// </remarks> public void InitializeModules(string modulesPath) { // add plugin tree Modules IModulePathNode node = ResolvePath(modulesPath); if (node == null) { return; } Hashtable modules = node.ChildNodes; // initialize all Modules foreach (IModulePathNode moduleNode in modules.Values) { DateTime now = DateTime.Now; if (moduleNode.Module != null) { moduleNode.Module.InitializeModule(); } } }
internal DefaultModulePathNode(string pathName, IModulePathNode parentNode) { path = pathName; parent = parentNode; }
/// <summary> /// Registers a subcontainer. The components exposed /// by this container will be accessible from subcontainers. /// </summary> /// <param name="childContainer"></param> public void AddModulePathNode(IModulePathNode childNode) { childNode.Parent = this; }