コード例 #1
0
ファイル: ConfigFileManager.cs プロジェクト: MASKEDRC/client
        /// <summary>
        /// Startet das parsen einer ConfigFile rekursiv
        /// </summary>
        /// <param name="cfgId"></param>
        /// <param name="bParseFromFile">Gibt an, ob die existierende evtl geänderte File aus dem Speicher oder die physikalisch vorhandene File neu geparst werden soll</param>
        public void parseConfig(int cfgId, bool bParseFromFile)
        {
            ConfigFile cfgFile = this.cfgFiles.Where(cfg => cfg.Id.Equals(cfgId)).First();

            if (bParseFromFile)
            {
                cfgFile.Commands = ConfigParser.parseConfigFile(cfgFile.Path);
            }

            cfgFile.validateCommandos();

            //Beziehungen zu anderen Files aufbauen
            //Alle gültigen Exec-Commands holen
            IEnumerable <Commando> execCmds = cfgFile.Commands.Where(cmd =>
                                                                     cmd.CommandType == CommandType.exec &&
                                                                     cmd.ValidationState == ValidationLevel.Ok);

            //bestehende Referenzen löschen
            cfgFile.SubConfigRef.Clear();

            foreach (Commando cmd in execCmds)
            {
                string path    = cfgFile.Path.Substring(0, cfgFile.Path.LastIndexOf('\\') + 1);
                CExec  execCmd = (CExec)cmd;
                path += execCmd.Filename;

                bool bLoopDetected = checkForCircle(path, cfgFile);
                if (bLoopDetected)
                {
                    execCmd.LoopDetected = true;
                }
                else
                {
                    int id;
                    if (bParseFromFile)
                    {
                        id = addConfig(path, false);
                    }
                    else
                    {
                        ConfigFile file = getConfigByPath(path);
                        if (file != null)
                        {
                            id = file.Id;
                        }
                        else
                        {
                            id             = addConfig(path, false);
                            bParseFromFile = true;
                        }
                    }
                    cfgFile.SubConfigRef.Add(new WeakReference(getConfigById(id)));
                    parseConfig(id, bParseFromFile);
                }
            }
        }
コード例 #2
0
 public void parse()
 {
     this.commands = ConfigParser.parseConfigFile(this.path);
 }