Example #1
0
        internal string[] Read(Type t, INIFile f, string defaultSection)
        {
            if (t != typeof(string[]))
            {
                throw new InvalidOperationException(Resource.Strings.Error_INIKeyListInvalidType.F(t.Name));
            }

            string        s    = INIAttributeExt.GetSection(Section, defaultSection);
            List <string> vals = new List <string>();

            if (f.HasSection(s))
            {
                foreach (INIFile.INISection.INILine ln in f.GetSection(s).Lines)
                {
                    if (ln.HasKey)
                    {
                        vals.Add(GetValue(ValueSource, ln.Key, ln.Value));
                    }
                }
            }
            else if (Required)
            {
                throw new INISectionNotFoundException(s);
            }

            return(vals.ToArray());
        }
Example #2
0
        private Registry <T, U> InnerRead <T, U>(INIFile f, string defaultSection, IResolver resolver)
        {
            string          s   = INIAttributeExt.GetSection(Section, defaultSection);
            Registry <T, U> ret = new Registry <T, U>();

            if (f.HasSection(s))
            {
                foreach (INIFile.INISection.INILine ln in f.GetSection(s).Lines)
                {
                    if (ln.HasKey)
                    {
                        ret.Add(Parser.Parse(ln.Key, default(T)), Parser.Parse(ln.Value, resolver, default(U)));
                    }
                }
            }
            else if (Required)
            {
                throw new INISectionNotFoundException(s);
            }

            return(ret);
        }