Exemplo n.º 1
0
        public IModule GetModule(string strModuleName)
        {
            MibModule module = null;

            if (!_loaded.TryGetValue(strModuleName, out module))
            {
                _pendings.TryGetValue(strModuleName, out module);
            }
            return(module);
        }
Exemplo n.º 2
0
        private bool CanParse(MibModule module)
        {
            if (!MibModule.AllDependentsAvailable(module, _loaded))
            {
                return(false);
            }

            bool exists = _loaded.ContainsKey(module.Name); // FIXME: don't parse the same module twice now.

            if (!exists)
            {
                _loaded.Add(module.Name, module);
            }

            return(true);
        }
Exemplo n.º 3
0
        private void Import(MibModule module)
        {
            if (module == null)
            {
                throw new ArgumentNullException("module");
            }

            if (LoadedModules.Contains(module.Name) || PendingModules.Contains(module.Name))
            {
                Logger.InfoFormat(CultureInfo.InvariantCulture, "{0} ignored", module.Name);
            }
            else
            {
                _pendings.Add(module.Name, module);
            }
        }
Exemplo n.º 4
0
        public ModuleLoader(TextReader reader, string moduleName)
        {
            _nodes      = new List <Definition>();
            _dependents = new List <string>();

            string line;

            while ((line = reader.ReadLine()) != null)
            {
                if (line.StartsWith("#", StringComparison.Ordinal))
                {
                    _dependents.AddRange(ParseDependents(line));
                    continue;
                }

                _nodes.Add(ParseLine(line, moduleName));
            }

            _module = new MibModule(moduleName, _dependents);
        }
Exemplo n.º 5
0
 internal static bool AllDependentsAvailable(MibModule module, IDictionary <string, MibModule> modules)
 {
     return(module.Dependents.All(dependent => DependentFound(dependent, modules)));
 }