Beispiel #1
0
        public static List <ConfigRow> ParseConfig(string FileName)
        {
            string Text = File.ReadAllText(FileName, Encoding.Default);

            if (Text == null)
            {
                return(null);
            }
            List <ConfigRow> Rows = new List <ConfigRow>();

            string[] Lines = StrHelper.Explode("\n", Text);
            for (int i = 0; i < Lines.Length; i++)
            {
                ConfigRow CurrentRow = ParseConfigRow(Lines[i]);
                if (CurrentRow != null)
                {
                    if (CurrentRow.Key == "+include")
                    {
                        string IncludeFile = FileName;
                        IncludeFile = IncludeFile.Substring(0, IncludeFile.LastIndexOf(@"\")) + @"\" + CurrentRow.Fields[0];
                        List <ConfigRow> Include = ParseConfig(IncludeFile);
                        if (Include != null)
                        {
                            Rows.AddRange(Include);
                        }
                    }
                    else
                    {
                        Rows.Add(CurrentRow);
                    }
                }
            }
            return(Rows);
        }
Beispiel #2
0
        public static List <ConfigRow> GetConfigRow(string Text)
        {
            if (Text == null)
            {
                return(null);
            }
            List <ConfigRow> Rows = new List <ConfigRow>();

            string[] Lines = StrHelper.Explode("\n", Text);
            for (int i = 0; i < Lines.Length; i++)
            {
                ConfigRow CurrentRow = ParseConfigRow(Lines[i]);
                if (CurrentRow != null)
                {
                    Rows.Add(CurrentRow);
                }
            }
            return(Rows);
        }