示例#1
0
        public Boolean Load(string fileName, string path)
        {
            var FileParser = new FileIniDataParser();

            Boolean isExist = FileParser.IsFileExists(fileName, path);

            if (!isExist)
            {
                return(false);
            }

            IniData data = FileParser.ReadIniFile(fileName, path, Encoding.ASCII);

            bool  bresult;
            float fresult;
            Menu  menu;

            SectionCollection sections = data.Sections;

            foreach (Section section in sections)
            {
                menu = new Menu(section.Name);

                foreach (Property property in section.Properties)
                {
                    if (Boolean.TryParse(property.Value, out bresult))
                    {
                        MenuEntryBool entry = new MenuEntryBool(property.Key, bresult);
                        menu.Add(entry);
                    }
                    else if (float.TryParse(property.Value, out fresult))
                    {
                        MenuEntryNumber entry = new MenuEntryNumber(property.Key, fresult);
                        menu.Add(entry);
                    }
                    else
                    {
                        MenuEntryString entry = new MenuEntryString(property.Key, property.Value);
                        menu.Add(entry);
                    }
                }

                Add(menu);
            }

            return(true);
        }