Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
use fluen modsink builder
Browse files Browse the repository at this point in the history
  • Loading branch information
j2ghz committed Jun 28, 2018
1 parent 00282ae commit 5212e15
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
6 changes: 1 addition & 5 deletions src/ModSink.Common/ModSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ namespace ModSink.Common
{
public class ModSink : IModSink
{
public ModSink(IHashFunction hashFunction, IClientService client, IServerManager server)
public ModSink( IClientService client)
{
this.HashFunction = hashFunction;
this.Client = client;
this.Server = server;
}

public IClientService Client { get; }
public IHashFunction HashFunction { get; }
public IServerManager Server { get; }
}
}
39 changes: 39 additions & 0 deletions src/ModSink.Common/ModSinkBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.IO;
using System.Runtime.Serialization;
using ModSink.Common.Client;
using ModSink.Core;
using ModSink.Core.Client;

namespace ModSink.Common
{
public class ModSinkBuilder
{
private IDownloader downloader;
private IFormatter formatter;
private DirectoryInfo localStorageDirectory;

public ModSinkBuilder WithDownloader(IDownloader downloader)
{
this.downloader = downloader;
return this;
}

public ModSinkBuilder WithFormatter(IFormatter formatter)
{
this.formatter = formatter;
return this;
}

public ModSinkBuilder InDirectory(DirectoryInfo directory)
{
localStorageDirectory = directory;
return this;
}

public IModSink Build()
{
return new ModSink(new ClientService(new DownloadService(downloader),
new LocalStorageService(localStorageDirectory), downloader, formatter));
}
}
}
2 changes: 0 additions & 2 deletions src/ModSink.Core/IModSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ namespace ModSink.Core
public interface IModSink
{
IClientService Client { get; }
IHashFunction HashFunction { get; }
IServerManager Server { get; }
}
}
9 changes: 6 additions & 3 deletions src/ModSink.WPF/ViewModel/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ public class MainWindowViewModel : ReactiveObject
{
public MainWindowViewModel()
{
var cs = new ClientService(new DownloadService(new HttpClientDownloader()),
new LocalStorageService(PathProvider.Downloads),
new HttpClientDownloader(), new BinaryFormatter());
var modsink = new ModSinkBuilder()
.WithDownloader(new HttpClientDownloader())
.WithFormatter(new BinaryFormatter())
.InDirectory(PathProvider.Downloads)
.Build();
var cs = modsink.Client;
DownloadsVM = new DownloadsViewModel(cs);
LibraryVM = new LibraryViewModel(cs);
SettingsVM = new SettingsViewModel(new SettingsModel(cs));
Expand Down

0 comments on commit 5212e15

Please sign in to comment.