Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/LogExpert.Tests/JSONSaveTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using LogExpert.Config;

using Newtonsoft.Json;

using NUnit.Framework;

using System.IO;

namespace LogExpert.Tests
Expand All @@ -17,14 +20,14 @@ public void SaveOptionsAsJSON()
string settingsFile = configDir + "\\settings.json";

Settings settings = null;

Assert.DoesNotThrow(CastSettings);
Assert.That(settings, Is.Not.Null);
Assert.That(settings.alwaysOnTop, Is.True);

ConfigManager.Settings.alwaysOnTop = false;
ConfigManager.Save(SettingsFlags.All);

settings = null;
Assert.DoesNotThrow(CastSettings);

Expand Down
42 changes: 21 additions & 21 deletions src/LogExpert/Classes/Log/PositionAwareStreamReaderBase.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using LogExpert.Config;
using LogExpert.Entities;

using System;
using System.IO;
using System.Text;
using LogExpert.Entities;

namespace LogExpert.Classes.Log
{
public abstract class PositionAwareStreamReaderBase : LogStreamReaderBase
{
#region Fields

private const int MAX_LINE_LEN = 20000;

private static readonly Encoding[] _preambleEncodings = { Encoding.UTF8, Encoding.Unicode, Encoding.BigEndianUnicode, Encoding.UTF32 };

private readonly BufferedStream _stream;
Expand All @@ -35,7 +35,7 @@ protected PositionAwareStreamReaderBase(Stream stream, EncodingOptions encodingO
_posIncPrecomputed = GetPosIncPrecomputed(usedEncoding);

_reader = new StreamReader(_stream, usedEncoding, true);

Position = 0;
}

Expand All @@ -54,7 +54,7 @@ public sealed override long Position
/*
* 1: Sometime commented (+Encoding.GetPreamble().Length)
* 2: Date 1.1 3207
* 3: Error Message from Piet because of Unicode-Bugs.
* 3: Error Message from Piet because of Unicode-Bugs.
* No Idea, if this is OK.
* 4: 27.07.09: Preamble-Length is now calculated in CT, because Encoding.GetPreamble().Length
* always delivers a fixed length (does not mater what kind of data)
Expand All @@ -72,7 +72,7 @@ public sealed override long Position

public sealed override bool IsBufferComplete => true;

protected static int MaxLineLen => MAX_LINE_LEN;
protected static int MaxLineLen => ConfigManager.Settings.preferences.MaxLineLength;

#endregion

Expand Down Expand Up @@ -149,11 +149,11 @@ protected void MovePosition(int offset)
private int DetectPreambleLengthAndEncoding(out Encoding detectedEncoding)
{
/*
UTF-8: EF BB BF
UTF-16-Big-Endian-Byteorder: FE FF
UTF-16-Little-Endian-Byteorder: FF FE
UTF-32-Big-Endian-Byteorder: 00 00 FE FF
UTF-32-Little-Endian-Byteorder: FF FE 00 00
UTF-8: EF BB BF
UTF-16-Big-Endian-Byteorder: FE FF
UTF-16-Little-Endian-Byteorder: FF FE
UTF-32-Big-Endian-Byteorder: 00 00 FE FF
UTF-32-Little-Endian-Byteorder: FF FE 00 00
*/

byte[] readPreamble = new byte[4];
Expand Down Expand Up @@ -205,17 +205,17 @@ private int GetPosIncPrecomputed(Encoding usedEncoding)
switch (usedEncoding)
{
case UTF8Encoding _:
{
return 0;
}
{
return 0;
}
case UnicodeEncoding _:
{
return 2;
}
{
return 2;
}
default:
{
return 1;
}
{
return 1;
}
}
}

Expand Down
Loading