diff --git a/src/ConfigParser.cs b/src/ConfigParser.cs
index 2aa34bc..c9fde03 100644
--- a/src/ConfigParser.cs
+++ b/src/ConfigParser.cs
@@ -208,6 +208,19 @@ public virtual string GetValue(string sectionName, string keyName, string defaul
return GetRawValue(sectionName, keyName, defaultValue);
}
+ /// Joins a multiline value using a separator.
+ /// Name of the section.
+ /// Name of the key.
+ /// The separator (defaults to whitespace).
+ ///
+ ///
+ ///
+ public string JoinMultilineValue(string sectionName, string keyName, string separator = " ")
+ {
+ var multiLineVal = GetValue(sectionName, keyName);
+ return string.Join(separator, multiLineVal?.Split(new[] { Settings.NewLine }, StringSplitOptions.None));
+ }
+
///
/// Gets the value.
///
diff --git a/tests/ConfigParserTests.cs b/tests/ConfigParserTests.cs
index 152ff12..ea2ef28 100644
--- a/tests/ConfigParserTests.cs
+++ b/tests/ConfigParserTests.cs
@@ -81,5 +81,25 @@ from table
Assert.Equal("from table", arrayValues[1]);
Assert.Equal("where ID = '5'", arrayValues[2]);
}
+
+ [Fact]
+ public void JoinMultilineValueWorks()
+ {
+ // Set up
+ var settings = new ConfigParserSettings { MultiLineValues = MultiLineValues.Simple };
+ var configFile = new ConfigParser(
+ @"[Advanced]
+ExampleValue = Lorem ipsum dolor sit amet
+consectetur adipiscing elit
+sed do eiusmod tempor incididunt
+ ",
+ settings);
+
+ // Act
+ var multiLineJoint = configFile.JoinMultilineValue("Advanced", "ExampleValue", " ");
+
+ // Assert
+ Assert.Equal("Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt", multiLineJoint);
+ }
}
}