Close() public method

public Close ( ) : void
return void
示例#1
0
        /// <summary>
        /// Loads the file not saving comments.
        /// </summary>
        private void LoadReader(IniReader reader)
        {
            reader.IgnoreComments = false;
            var        sectionFound = false;
            IniSection section      = null;

            try {
                while (reader.Read())
                {
                    switch (reader.Type)
                    {
                    case IniType.Empty:
                        if (!sectionFound)
                        {
                            initialComment.Add(reader.Comment);
                        }
                        else
                        {
                            section.Set(reader.Comment);
                        }

                        break;

                    case IniType.Section:
                        sectionFound = true;
                        // If section already exists then overwrite it
                        if (sections[reader.Name] != null)
                        {
                            sections.Remove(reader.Name);
                        }
                        section = new IniSection(reader.Name, reader.Comment);
                        sections.Add(section);

                        break;

                    case IniType.Key:
                        if (section.GetValue(reader.Name) == null)
                        {
                            section.Set(reader.Name, reader.Value, reader.Comment);
                        }
                        break;
                    }
                }
            }
            catch (Exception ex) {
                throw;
            }
            finally {
                // Always close the file
                reader.Close();
            }
        }
示例#2
0
        /// <summary>
        /// Loads the file not saving comments.
        /// </summary>
        private void LoadReader(IniReader reader) {
            reader.IgnoreComments = false;
            var sectionFound = false;
            IniSection section = null;

            try {
                while(reader.Read()) {
                    switch(reader.Type) {
                        case IniType.Empty:
                            if(!sectionFound) {
                                initialComment.Add(reader.Comment);
                            }
                            else {
                                section.Set(reader.Comment);
                            }

                            break;
                        case IniType.Section:
                            sectionFound = true;
                            // If section already exists then overwrite it
                            if(sections[reader.Name] != null) {
                                sections.Remove(reader.Name);
                            }
                            section = new IniSection(reader.Name, reader.Comment);
                            sections.Add(section);

                            break;
                        case IniType.Key:
                            if(section.GetValue(reader.Name) == null) {
                                section.Set(reader.Name, reader.Value, reader.Comment);
                            }
                            break;
                    }
                }
            }
            catch(Exception ex) {
                throw;
            }
            finally {
                // Always close the file
                reader.Close();
            }
        }