Permalink
Browse files

Remove default constructor on MainViewModel, setup SimpleIoC

  • Loading branch information...
Dirk Rombauts
Dirk Rombauts committed Jul 15, 2014
1 parent b429c6a commit cdb62ff30105b119d4dd11fc811581145b9b91d1
@@ -89,12 +89,6 @@ public class MainViewModel : ViewModelBase
private bool isDocumentationFormatValid;
- [PreferredConstructor]
- public MainViewModel()
- : this(new MainModelSerializer(DataDirectoryDeriver.DeriveDataDirectory(), new FileSystem()), new FileSystem())
- {
- }
-
public MainViewModel(IMainModelSerializer mainModelSerializer, IFileSystem fileSystem)
{
this.documentationFormats = new MultiSelectableCollection<DocumentationFormat>(Enum.GetValues(typeof(DocumentationFormat)).Cast<DocumentationFormat>());
@@ -512,7 +506,7 @@ private void DoWork()
{
var builder = new ContainerBuilder();
builder.RegisterAssemblyTypes(typeof(Runner).Assembly);
- builder.Register<FileSystem>(_ => new FileSystem()).As<IFileSystem>().SingleInstance();
+ builder.Register<IFileSystem>(_ => this.fileSystem).SingleInstance();
builder.RegisterModule<PicklesModule>();
var container = builder.Build();
@@ -12,10 +12,13 @@
See http://www.galasoft.ch/mvvm
*/
-using GalaSoft.MvvmLight;
+using System.IO.Abstractions;
+
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;
+using PicklesDoc.Pickles.UserInterface.Settings;
+
namespace PicklesDoc.Pickles.UserInterface.ViewModel
{
/// <summary>
@@ -29,7 +32,7 @@ public class ViewModelLocator
/// </summary>
public ViewModelLocator()
{
- ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
+ ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
////if (ViewModelBase.IsInDesignModeStatic)
////{
@@ -42,9 +45,13 @@ public ViewModelLocator()
//// SimpleIoc.Default.Register<IDataService, DataService>();
////}
- SimpleIoc.Default.Register<MainViewModel>();
+ var fileSystem = new FileSystem();
+ SimpleIoc.Default.Register<IFileSystem>(() => fileSystem);
+ SimpleIoc.Default.Register<IMainModelSerializer>(() => new MainModelSerializer(DataDirectoryDeriver.DeriveDataDirectory(), fileSystem));
+ SimpleIoc.Default.Register<MainViewModel>();
}
+
public MainViewModel Main
{
get

0 comments on commit cdb62ff

Please sign in to comment.