diff --git a/Filtration/App.xaml.cs b/Filtration/App.xaml.cs index 2c37286..6c991f5 100644 --- a/Filtration/App.xaml.cs +++ b/Filtration/App.xaml.cs @@ -1,8 +1,15 @@ -using System.Linq; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Runtime.InteropServices.ComTypes; using System.Windows; +using AutoMapper; using Castle.MicroKernel.ModelBuilder.Inspectors; using Castle.Windsor; using Castle.Windsor.Installer; +using Filtration.Models; +using Filtration.Utilities; +using Filtration.ViewModels; using Filtration.Views; namespace Filtration @@ -16,26 +23,73 @@ namespace Filtration _container = new WindsorContainer(); var propInjector = _container.Kernel.ComponentModelBuilder - .Contributors - .OfType() - .Single(); + .Contributors + .OfType() + .Single(); _container.Kernel.ComponentModelBuilder.RemoveContributor(propInjector); _container.Install(FromAssembly.This()); + + // TODO: Find out how to parameterise this to map differently depending if ShowAdvanced is true or false. + //Mapper.CreateMap() + // .ForMember(dest => dest.IsChecked, + // opts => opts.MapFrom(from => from.IsChecked)) + // .ForMember(dest => dest.SourceBlockGroup, + // opts => opts.MapFrom(from => from)); + + //Mapper.CreateMap() + // .ForMember(dest => dest.IsChecked, + // opts => opts.MapFrom(from => from.IsChecked)) + // .ForMember(dest => dest.ChildGroups, + // opts => opts.ResolveUsing()) + // .ForMember(dest => dest.SourceBlockGroup, + // opts => opts.MapFrom(from => from)); + + //.ForMember(dest => dest.ChildGroups, + // opts => opts.Condition(src => src.Advanced == false)) + + //opts => opts.ResolveUsing()) + + //opts => opts.MapFrom(from => from.ChildGroups)) + + //Mapper.AssertConfigurationIsValid(); + var mainWindow = _container.Resolve(); mainWindow.Show(); - - //String[] arguments = Environment.GetCommandLineArgs(); - - //if (arguments.GetLength(0) <= 1) return; - //if (!arguments[1].EndsWith(".filter")) return; - - //var filePathFormMainArgs = arguments[1]; - //mainWindow.OpenScriptFromCommandLineArgument(filePathFormMainArgs); } + + //private class ChildGroupsResolver : ValueResolver + //{ + // protected override ItemFilterBlockGroupViewModel ResolveCore(ItemFilterBlockGroup source) + // { + // return !source.Advanced ? Mapper.Map(source) : null; + // } + //} + + //private class ChildGroupsResolver : + // ValueResolver, ObservableCollection> + //{ + // protected override ObservableCollection ResolveCore(List source) + // { + // var result = new ObservableCollection(); + + // if (source != null && source.Count > 0) + // { + + // var filteredSource = source.Where(g => g.Advanced == false); + // foreach (var blockGroup in filteredSource) + // { + // result.Add(Mapper.Map(blockGroup)); + // } + // } + + // return result; + // } + //} + protected override void OnExit(ExitEventArgs e) { _container.Dispose(); diff --git a/Filtration/Filtration.csproj b/Filtration/Filtration.csproj index ef1b316..972a3d0 100644 --- a/Filtration/Filtration.csproj +++ b/Filtration/Filtration.csproj @@ -41,6 +41,12 @@ Resources\filtration.ico + + ..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.dll + + + ..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.Net4.dll + ..\packages\Castle.Core.3.3.0\lib\net45\Castle.Core.dll @@ -175,6 +181,8 @@ ItemPreviewControl.xaml + + @@ -182,6 +190,7 @@ + @@ -425,6 +434,7 @@ + + - @@ -24,12 +22,12 @@