Skip to content

Commit 98e7de6

Browse files
committed
add offline data provider example
1 parent 116bb98 commit 98e7de6

File tree

8 files changed

+100
-28
lines changed

8 files changed

+100
-28
lines changed

Analogy.LogViewer.Example.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>Analogy.LogViewer.Example</id>
5-
<version>1.0.6.0</version>
5+
<version>1.0.7.0</version>
66
<title>Analogy Log Viewer - Example</title>
77
<authors>Lior Banai</authors>
88
<owners>Lior Banai</owners>

Analogy.LogViewer.Example/Analogy.LogViewer.Example.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@
4343
<Reference Include="System.Xml" />
4444
</ItemGroup>
4545
<ItemGroup>
46-
<Compile Include="AnalogyDataSourceFactory.cs" />
47-
<Compile Include="AnalogyExampleFactory.cs" />
48-
<Compile Include="AnalogyOnlineExampleDataProvider.cs" />
46+
<Compile Include="ExampleDataProviderFactory.cs" />
47+
<Compile Include="ExampleFactory.cs" />
48+
<Compile Include="OnlineExampleDataProvider.cs" />
49+
<Compile Include="OfflineExampleDataProvider.cs" />
4950
<Compile Include="Properties\AssemblyInfo.cs" />
5051
</ItemGroup>
5152
<ItemGroup>

Analogy.LogViewer.Example/AnalogyDataSourceFactory.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Analogy.Interfaces;
4+
using Analogy.Interfaces.Factories;
5+
6+
namespace Analogy.LogViewer.Example
7+
{
8+
public class ExampleDataProviderFactory : IAnalogyDataProvidersFactory
9+
{
10+
public string Title => "Analogy Online example";
11+
12+
public IEnumerable<IAnalogyDataProvider> Items => new List<IAnalogyDataProvider>
13+
{
14+
//add 2 "real time data providers"
15+
new OnlineExampleDataProvider("Data Provider 1", new Guid("6642B160-F992-4120-B688-B02DE2E83256")),
16+
new OnlineExampleDataProvider("Data Provider 2", new Guid("5AB690DC-545B-4150-B2CD-2534B2ACBF82")),
17+
//add 2 "offline data providers"
18+
new OfflineExampleDataProvider("Data Provider 1", new Guid("2BFC1602-17EF-447D-8DDC-8A00F46C1CE1")),
19+
new OfflineExampleDataProvider("Data Provider 2", new Guid("B22D4BD1-10D7-460B-ADCE-849E73BCA91D")),
20+
21+
};
22+
}
23+
}

Analogy.LogViewer.Example/AnalogyExampleFactory.cs renamed to Analogy.LogViewer.Example/ExampleFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
namespace Analogy.LogViewer.Example
77
{
8-
public class AnalogyExampleFactory : IAnalogyFactory
8+
public class ExampleFactory : IAnalogyFactory
99
{
1010
public Guid FactoryID => new Guid("4B1EBC0F-64DD-44A1-BC27-79DBFC6384CC");
1111

1212
public string Title => "Analogy Examples";
1313

14-
public IAnalogyDataProvidersFactory DataProviders { get; } = new AnalogyDataProviderFactory();
14+
public IAnalogyDataProvidersFactory DataProviders { get; } = new ExampleDataProviderFactory();
1515

1616
public IAnalogyCustomActionsFactory Actions => null;
1717

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using Analogy.Interfaces;
9+
10+
namespace Analogy.LogViewer.Example
11+
{
12+
class OfflineExampleDataProvider : IAnalogyOfflineDataProvider
13+
{
14+
15+
public Guid ID { get; }
16+
public string OptionalTitle { get; }
17+
18+
public bool CanSaveToLogFile { get; } = false;
19+
public string FileOpenDialogFilters { get; } = "All supported Analogy log file types|*.log;*.json|Plain Analogy XML log file (*.log)|*.log|Analogy JSON file (*.json)|*.json";
20+
public string FileSaveDialogFilters { get; }=String.Empty;
21+
public IEnumerable<string> SupportFormats { get; } = new[] { "*.log", "*.json" };
22+
public string InitialFolderFullPath { get; } = Environment.CurrentDirectory;
23+
24+
public OfflineExampleDataProvider(string prefix, Guid guid)
25+
{
26+
ID = guid;
27+
OptionalTitle = $"Analogy Example: Offline Data Provider ({prefix})";
28+
}
29+
30+
public Task InitializeDataProviderAsync()
31+
{
32+
return Task.CompletedTask;
33+
}
34+
35+
public void MessageOpened(AnalogyLogMessage message)
36+
{
37+
//nop
38+
}
39+
40+
public Task<IEnumerable<AnalogyLogMessage>> Process(string fileName, CancellationToken token, ILogMessageCreatedHandler messagesHandler)
41+
{
42+
return Task.FromResult(new List<AnalogyLogMessage>(0).AsEnumerable());
43+
}
44+
45+
public IEnumerable<FileInfo> GetSupportedFiles(DirectoryInfo dirInfo, bool recursiveLoad)
46+
{
47+
return new List<FileInfo>(0);
48+
}
49+
50+
public Task SaveAsync(List<AnalogyLogMessage> messages, string fileName)
51+
{
52+
return Task.CompletedTask;
53+
}
54+
55+
public bool CanOpenFile(string fileName)
56+
{
57+
return true;
58+
}
59+
60+
public bool CanOpenAllFiles(IEnumerable<string> fileNames)
61+
{
62+
return fileNames.All(CanOpenFile);
63+
}
64+
65+
}
66+
}

Analogy.LogViewer.Example/AnalogyOnlineExampleDataProvider.cs renamed to Analogy.LogViewer.Example/OnlineExampleDataProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Analogy.LogViewer.Example
1010
{
11-
class AnalogyOnlineExampleDataProvider : IAnalogyRealTimeDataProvider
11+
class OnlineExampleDataProvider : IAnalogyRealTimeDataProvider
1212
{
1313
public string OptionalTitle { get; }
1414
public Guid ID {get;}
@@ -28,7 +28,7 @@ class AnalogyOnlineExampleDataProvider : IAnalogyRealTimeDataProvider
2828
readonly Array values = Enum.GetValues(typeof(AnalogyLogLevel));
2929
private readonly List<string> processes = Process.GetProcesses().Select(p => p.ProcessName).ToList();
3030
private readonly string prefixMessage;
31-
public AnalogyOnlineExampleDataProvider(string prefix,Guid guid)
31+
public OnlineExampleDataProvider(string prefix,Guid guid)
3232
{
3333
prefixMessage = prefix;
3434
ID = guid;

Analogy.LogViewer.Example/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.0.6.0")]
35-
[assembly: AssemblyFileVersion("1.0.6.0")]
34+
[assembly: AssemblyVersion("1.0.7.0")]
35+
[assembly: AssemblyFileVersion("1.0.7.0")]

0 commit comments

Comments
 (0)