Skip to content

Commit 1af5096

Browse files
stop using params when current implementation only ever has two values
1 parent 6df7cae commit 1af5096

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/Serilog.Sinks.File/Sinks/File/FileLifecycleHooksExtensions.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,27 @@ public static FileLifecycleHooks ChainTo(this FileLifecycleHooks first, FileLife
4343

4444
class FileLifeCycleHookChain : FileLifecycleHooks
4545
{
46-
private readonly FileLifecycleHooks[] hooks;
46+
private readonly FileLifecycleHooks _first;
47+
private readonly FileLifecycleHooks _second;
4748

48-
public FileLifeCycleHookChain(params FileLifecycleHooks[] hooks)
49+
public FileLifeCycleHookChain(FileLifecycleHooks first, FileLifecycleHooks second)
4950
{
50-
this.hooks = hooks ?? throw new ArgumentNullException(nameof(hooks));
51+
_first = first ?? throw new ArgumentNullException(nameof(first));
52+
_second = second ?? throw new ArgumentNullException(nameof(second));
5153
}
5254

5355
public override Stream OnFileOpened(Stream underlyingStream, Encoding encoding)
5456
{
55-
for (int i = 0; i < hooks.Length; i++)
56-
{
57-
underlyingStream = hooks[i].OnFileOpened(underlyingStream, encoding);
58-
}
59-
return underlyingStream;
57+
var firstStreamResult = _first.OnFileOpened(underlyingStream, encoding);
58+
var secondStreamResult = _second.OnFileOpened(firstStreamResult, encoding);
59+
60+
return secondStreamResult;
6061
}
6162

6263
public override void OnFileDeleting(string path)
6364
{
64-
for (int i = 0; i < hooks.Length; i++)
65-
{
66-
hooks[i].OnFileDeleting(path);
67-
}
65+
_first.OnFileDeleting(path);
66+
_second.OnFileDeleting(path);
6867
}
6968
}
7069
}

0 commit comments

Comments
 (0)