Пример #1
0
        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);
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        /// <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);
            }
        }
Пример #4
0
 /// <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);
         }
     }
 }
Пример #5
0
        /// <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();
                }
            }
        }
Пример #6
0
 internal DefaultModulePathNode(string pathName, IModulePathNode parentNode)
 {
     path = pathName;
     parent = parentNode;
 }
Пример #7
0
 /// <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;
 }
Пример #8
0
 /// <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;
 }
Пример #9
0
 internal DefaultModulePathNode(string pathName, IModulePathNode parentNode)
 {
     path   = pathName;
     parent = parentNode;
 }