Пример #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);
        }
Пример #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());
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Use to create an <see cref="IniDocument"/>
 /// <para> Pass in an existing <see cref="IniDocument"/> for manipulation or to create a deep clone.</para>
 /// </summary>
 /// <param name="document">The <see cref="IniDocument"/> for cloning or manipulation.</param>
 /// <returns>Returns a new <see cref="IniDocumentBuilder"/>.</returns>
 public static IniDocumentBuilder Builder(IniDocument document = null)
 {
     return(new IniDocumentBuilder(document));
 }