/// <summary> /// Returns a proper INI reader depending upon the type parameter. /// </summary> private IniReader GetIniReader(TextReader reader, IniFileType type) { IniReader result = new IniReader(reader); switch (type) { case IniFileType.Standard: // do nothing break; case IniFileType.PythonStyle: result.AcceptCommentAfterKey = false; result.SetCommentDelimiters(new char[] { ';', '#' }); result.SetAssignDelimiters(new char[] { ':' }); break; case IniFileType.SambaStyle: result.AcceptCommentAfterKey = false; result.SetCommentDelimiters(new char[] { ';', '#' }); result.LineContinuation = true; break; case IniFileType.MysqlStyle: result.AcceptCommentAfterKey = false; result.AcceptNoAssignmentOperator = true; result.SetCommentDelimiters(new char[] { '#' }); result.SetAssignDelimiters(new char[] { ':', '=' }); break; case IniFileType.WindowsStyle: result.ConsumeAllKeyText = true; break; } return(result); }
public void GetAndSetDelimiters() { StringWriter writer = new StringWriter(); writer.WriteLine("[Test]"); writer.WriteLine(" option = someValue ; some comment"); IniReader reader = new IniReader (new StringReader(writer.ToString())); Assert.AreEqual('=', reader.GetAssignDelimiters()[0]); reader.SetAssignDelimiters(new char[] { ':', '=' }); Assert.AreEqual(':', reader.GetAssignDelimiters()[0]); Assert.AreEqual('=', reader.GetAssignDelimiters()[1]); Assert.AreEqual(';', reader.GetCommentDelimiters()[0]); reader.SetCommentDelimiters(new char[] { '#', ';' }); Assert.AreEqual('#', reader.GetCommentDelimiters()[0]); Assert.AreEqual(';', reader.GetCommentDelimiters()[1]); }
/// <summary> /// Returns a proper INI reader depending upon the type parameter. /// </summary> private IniReader GetIniReader(TextReader reader, IniFileType type) { IniReader result = new IniReader(reader); switch(type) { case IniFileType.Standard: // do nothing break; case IniFileType.PythonStyle: result.AcceptCommentAfterKey = false; result.SetCommentDelimiters(new char[] { ';', '#' }); result.SetAssignDelimiters(new char[] { ':' }); break; case IniFileType.SambaStyle: result.AcceptCommentAfterKey = false; result.SetCommentDelimiters(new char[] { ';', '#' }); result.LineContinuation = true; break; case IniFileType.MysqlStyle: result.AcceptCommentAfterKey = false; result.AcceptNoAssignmentOperator = true; result.SetCommentDelimiters(new char[] { '#' }); result.SetAssignDelimiters(new char[] { ':', '=' }); break; case IniFileType.WindowsStyle: result.ConsumeAllKeyText = true; break; } return result; }