Ejemplo n.º 1
0
        /// <summary>
        /// Merge another <see cref="IniDocument"/> with the current one.
        /// </summary>
        /// <param name="other">The other <see cref="IniDocument"/>.</param>
        public IniDocumentBuilder Merge(IniDocument other)
        {
            if (other == null)
            {
                return(this);
            }

            if (string.IsNullOrWhiteSpace(_filePath))
            {
                _filePath = other.FilePath;
            }

            if (_loadEndedAtIndex < 0)
            {
                _loadEndedAtIndex = other.LoadEndedAtIndex;
            }

            _header = Comment.Builder(_header).Merge(other.Header).Build();
            _footer = Comment.Builder(_footer).Merge(other.Footer).Build();

            for (var i = 0; i < other.Sections().Count; i++)
            {
                AppendSection(other.Sections()[i]);
            }

            return(this);
        }
Ejemplo n.º 2
0
        internal IniDocumentBuilder(IniDocument document)
        {
            if (document != null)
            {
                _header           = Comment.Builder(document.Header).Build();
                _footer           = Comment.Builder(document.Footer).Build();
                _isEnabled        = document.IsEnabled;
                _filePath         = document.FilePath;
                _loadEndedAtIndex = document.LoadEndedAtIndex;

                for (int i = 0; i < document.Sections().Count; i++)
                {
                    _sections.Add(Section.Builder(document.Sections()[i]).Build());
                }
            }
        }