コード例 #1
0
ファイル: Iniparser.cs プロジェクト: DiosnaCS/UsersDiosna-New
        public void ParseCfg(CIniFile config, string[] separators, CIniFile iniFileInstance)
        {
            string[] separeted_string = null;

            CView         lastView         = null;
            CField        lastField        = null;
            CSignal       lastSignal       = null;
            CSigMultitext lastSigMultitext = null;

            string[] lines = System.IO.File.ReadAllLines(CfgPath, System.Text.Encoding.Default);

            for (int i = 0; i < lines.Length; i++)
            {
                separeted_string = lines[i].Split(separators, StringSplitOptions.RemoveEmptyEntries);

                try
                {
                    if (!(lines[i].StartsWith("#")) && (lines[i].Length != 0))
                    {
                        switch (separeted_string[0])
                        {
                        case "View":
                            separeted_string = lines[i].Split(Const.separators_view, StringSplitOptions.RemoveEmptyEntries);
                            lastView         = parseView(config, separeted_string);
                            iniFileInstance.AddView(lastView);
                            break;

                        case "Field":
                            lastField = parseField(config, separeted_string);
                            lastView.AddField(lastField);
                            break;

                        case "Signal":
                            separeted_string = lines[i].Split(Const.separators_signal, StringSplitOptions.RemoveEmptyEntries);
                            lastSignal       = parseSignal(config, separeted_string);
                            lastField.AddSignal(lastSignal);
                            break;

                        case "SigMultitext":
                            separeted_string = lines[i].Split(Const.separators_signal, StringSplitOptions.RemoveEmptyEntries);
                            lastSigMultitext = parseSigMultitext(config, separeted_string);
                            lastField.AddSignalMultitext(lastSigMultitext);
                            break;
                        }
                    }
                }
                catch (Exception e) {
                    Error.toFile(e.Message.ToString(), this.GetType().Name.ToString());
                }
            }
        }