-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathUlsEnumerable.cs
More file actions
39 lines (34 loc) · 1.13 KB
/
UlsEnumerable.cs
File metadata and controls
39 lines (34 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reactive;
namespace UlsLogs
{
class UlsEnumerable
{
public static IEnumerable<UlsRecord> FromFiles(params string[] ulsFiles)
{
if (ulsFiles.Length == 1)
return FromFile(ulsFiles[0]);
var inputs = from file in ulsFiles select FromFile(file).GetEnumerator();
return new PullMergeSort<UlsRecord>(e => e.Time.DateTime, inputs);
}
static IEnumerable<UlsRecord> FromFile(string ulsFile)
{
using (TextReader reader = File.OpenText(ulsFile))
{
int lineNumber = 0; // for debugging
for (; ; )
{
string line = reader.ReadLine();
if (line == null)
yield break;
lineNumber++;
yield return new UlsRecord(line);
}
}
}
}
}