diff --git a/src/IF.Lastfm.Core/Api/Commands/LastAsyncCommandBase.cs b/src/IF.Lastfm.Core/Api/Commands/LastAsyncCommandBase.cs index b8b3e06..9b53550 100644 --- a/src/IF.Lastfm.Core/Api/Commands/LastAsyncCommandBase.cs +++ b/src/IF.Lastfm.Core/Api/Commands/LastAsyncCommandBase.cs @@ -12,19 +12,19 @@ namespace IF.Lastfm.Core.Api.Commands public abstract class LastAsyncCommandBase { public string Method { get; protected set; } + + public Dictionary Parameters { get; set; } } public abstract class LastAsyncCommandBase : LastAsyncCommandBase, IAsyncCommand where T : LastResponse, new() { - public Uri Url { get; protected set; } - public ILastAuth Auth { get; protected set; } public int Page { get; set; } public int Count { get; set; } - public Dictionary Parameters { get; set; } + public Uri Url { get; protected set; } protected LastAsyncCommandBase() { diff --git a/src/IF.Lastfm.Core/Api/Commands/PostAsyncCommandBase.cs b/src/IF.Lastfm.Core/Api/Commands/PostAsyncCommandBase.cs index 2ce96ca..d409790 100644 --- a/src/IF.Lastfm.Core/Api/Commands/PostAsyncCommandBase.cs +++ b/src/IF.Lastfm.Core/Api/Commands/PostAsyncCommandBase.cs @@ -23,12 +23,7 @@ public override async Task ExecuteAsync() SetParameters(); Url = BuildRequestUrl(); - - if (Auth.Authenticated) - { - Parameters.Add("sk", Auth.UserSession.Token); - } - + var apisig = Auth.GenerateMethodSignature(Method, Parameters); var postContent = LastFm.CreatePostBody(Method, diff --git a/src/IF.Lastfm.Core/Api/LastAuth.cs b/src/IF.Lastfm.Core/Api/LastAuth.cs index 9866e7b..965fe29 100644 --- a/src/IF.Lastfm.Core/Api/LastAuth.cs +++ b/src/IF.Lastfm.Core/Api/LastAuth.cs @@ -59,6 +59,10 @@ public string GenerateMethodSignature(string method, Dictionary parameters.Add("api_key", ApiKey); parameters.Add("method", method); + if (Authenticated) + { + parameters.Add("sk", UserSession.Token); + } var builder = new StringBuilder(); diff --git a/src/IF.Lastfm.Core/LastFm.cs b/src/IF.Lastfm.Core/LastFm.cs index 0c9a2df..db6e97b 100644 --- a/src/IF.Lastfm.Core/LastFm.cs +++ b/src/IF.Lastfm.Core/LastFm.cs @@ -9,7 +9,7 @@ using System.Text; [assembly: InternalsVisibleTo("IF.Lastfm.Core.Tests")] -[assembly: InternalsVisibleTo("IF.Lastfm.ProgressReport")] +[assembly: InternalsVisibleTo("IF.Lastfm.Syro")] namespace IF.Lastfm.Core { public class LastFm diff --git a/src/IF.Lastfm.Core/Objects/Shout.cs b/src/IF.Lastfm.Core/Objects/Shout.cs index 986ae15..9bb46e9 100644 --- a/src/IF.Lastfm.Core/Objects/Shout.cs +++ b/src/IF.Lastfm.Core/Objects/Shout.cs @@ -7,7 +7,7 @@ namespace IF.Lastfm.Core.Objects { - public class Shout + public class Shout : ILastfmObject { #region Properties diff --git a/src/IF.Lastfm.Demo.Apollo/IF.Lastfm.Demo.Apollo.csproj b/src/IF.Lastfm.Demo.Apollo/IF.Lastfm.Demo.Apollo.csproj index 518426a..252dd90 100644 --- a/src/IF.Lastfm.Demo.Apollo/IF.Lastfm.Demo.Apollo.csproj +++ b/src/IF.Lastfm.Demo.Apollo/IF.Lastfm.Demo.Apollo.csproj @@ -249,7 +249,6 @@ --> - diff --git a/src/IF.Lastfm.Syro/Helpers/AsyncDelegateCommand.cs b/src/IF.Lastfm.Syro/Helpers/AsyncDelegateCommand.cs index 8c937ca..9db10b5 100644 --- a/src/IF.Lastfm.Syro/Helpers/AsyncDelegateCommand.cs +++ b/src/IF.Lastfm.Syro/Helpers/AsyncDelegateCommand.cs @@ -2,7 +2,7 @@ using System.Threading.Tasks; using System.Windows.Input; -namespace IF.Common.Metro.Mvvm +namespace IF.Lastfm.Syro.Helpers { public class AsyncDelegateCommand : ICommand { diff --git a/src/IF.Lastfm.Syro/Helpers/DelegateCommand.cs b/src/IF.Lastfm.Syro/Helpers/DelegateCommand.cs index 1ef782c..e79aaa1 100644 --- a/src/IF.Lastfm.Syro/Helpers/DelegateCommand.cs +++ b/src/IF.Lastfm.Syro/Helpers/DelegateCommand.cs @@ -1,7 +1,7 @@ using System; using System.Windows.Input; -namespace IF.Common.Metro.Mvvm +namespace IF.Lastfm.Syro.Helpers { public class DelegateCommand : ICommand { diff --git a/src/IF.Lastfm.Syro/Helpers/DummyGetAsyncCommand.cs b/src/IF.Lastfm.Syro/Helpers/DummyGetAsyncCommand.cs new file mode 100644 index 0000000..17f1e72 --- /dev/null +++ b/src/IF.Lastfm.Syro/Helpers/DummyGetAsyncCommand.cs @@ -0,0 +1,31 @@ +using IF.Lastfm.Core.Api; +using IF.Lastfm.Core.Api.Commands; +using IF.Lastfm.Core.Api.Helpers; +using Newtonsoft.Json.Linq; +using System.Net.Http; +using System.Threading.Tasks; + +namespace IF.Lastfm.Syro.Helpers +{ + public class DummyGetAsyncCommand : GetAsyncCommandBase, IDummyCommand where T : LastResponse, new() + { + public JObject Response { get; set; } + + public DummyGetAsyncCommand(ILastAuth auth) + : base(auth) + { + } + + public override void SetParameters() + { + } + + public async override Task HandleResponse(HttpResponseMessage response) + { + var json = await response.Content.ReadAsStringAsync(); + Response = JObject.Parse(json); + + return null; + } + } +} \ No newline at end of file diff --git a/src/IF.Lastfm.Syro/Helpers/DummyPostAsyncCommand.cs b/src/IF.Lastfm.Syro/Helpers/DummyPostAsyncCommand.cs new file mode 100644 index 0000000..3056c03 --- /dev/null +++ b/src/IF.Lastfm.Syro/Helpers/DummyPostAsyncCommand.cs @@ -0,0 +1,31 @@ +using System.IO; +using System.Net.Http; +using System.Threading.Tasks; +using IF.Lastfm.Core.Api; +using IF.Lastfm.Core.Api.Commands; +using IF.Lastfm.Core.Api.Helpers; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace IF.Lastfm.Syro.Helpers +{ + public class DummyPostAsyncCommand : PostAsyncCommandBase, IDummyCommand where T : LastResponse, new() + { + public JObject Response { get; private set; } + public DummyPostAsyncCommand(ILastAuth auth) : base(auth) + { + } + + public override void SetParameters() + { + } + + public async override Task HandleResponse(HttpResponseMessage response) + { + var json = await response.Content.ReadAsStringAsync(); + Response = JObject.Parse(json); + + return null; + } + } +} \ No newline at end of file diff --git a/src/IF.Lastfm.Syro/Helpers/IDummyCommand.cs b/src/IF.Lastfm.Syro/Helpers/IDummyCommand.cs new file mode 100644 index 0000000..b305a1d --- /dev/null +++ b/src/IF.Lastfm.Syro/Helpers/IDummyCommand.cs @@ -0,0 +1,9 @@ +using Newtonsoft.Json.Linq; + +namespace IF.Lastfm.Syro.Helpers +{ + public interface IDummyCommand + { + JObject Response { get; } + } +} \ No newline at end of file diff --git a/src/IF.Lastfm.Syro/Helpers/Pair.cs b/src/IF.Lastfm.Syro/Helpers/Pair.cs new file mode 100644 index 0000000..b5295c9 --- /dev/null +++ b/src/IF.Lastfm.Syro/Helpers/Pair.cs @@ -0,0 +1,57 @@ +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace IF.Lastfm.Syro.Helpers +{ + public class Pair : INotifyPropertyChanged + { + private TK _key; + private TV _value; + + public TK Key + { + get { return _key; } + set + { + if (Equals(_key, value)) return; + _key = value; + NotifyPropertyChanged(); + } + } + + public TV Value + { + get { return _value; } + set + { + if (Equals(_value, value)) return; + _value = value; + NotifyPropertyChanged(); + } + } + + public Pair() + { + } + + public Pair(TK key, TV value) + : this() + { + Key = key; + Value = value; + } + + #region INotifyPropertyChanged Members + + public event PropertyChangedEventHandler PropertyChanged; + + private void NotifyPropertyChanged([CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new PropertyChangedEventArgs(propertyName)); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/IF.Lastfm.Syro/IF.Lastfm.Syro.csproj b/src/IF.Lastfm.Syro/IF.Lastfm.Syro.csproj index fc07591..9ef0e56 100644 --- a/src/IF.Lastfm.Syro/IF.Lastfm.Syro.csproj +++ b/src/IF.Lastfm.Syro/IF.Lastfm.Syro.csproj @@ -56,6 +56,10 @@ ..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + + False + ..\..\packages\Newtonsoft.Json.6.0.5\lib\net45\Newtonsoft.Json.dll + @@ -87,11 +91,16 @@ Designer + + + + - + + diff --git a/src/IF.Lastfm.Syro/MainWindow.xaml b/src/IF.Lastfm.Syro/MainWindow.xaml index 27434eb..15aa32b 100644 --- a/src/IF.Lastfm.Syro/MainWindow.xaml +++ b/src/IF.Lastfm.Syro/MainWindow.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls" Height="350" - MinHeight="300" + MinHeight="500" MinWidth="400" Width="525" Foreground="#111111" diff --git a/src/IF.Lastfm.Syro/Pages/MainPage.xaml b/src/IF.Lastfm.Syro/Pages/MainPage.xaml index c57864a..951feed 100644 --- a/src/IF.Lastfm.Syro/Pages/MainPage.xaml +++ b/src/IF.Lastfm.Syro/Pages/MainPage.xaml @@ -1,20 +1,140 @@ - - + + - + - Coming soon... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -23,36 +143,42 @@ + Margin="0,0,0,10" /> + Margin="0,0,0,15" /> + Height="30" /> - + - % complete, commands left + % complete, + commands left + + Open PROGRESS.md + + - + \ No newline at end of file diff --git a/src/IF.Lastfm.Syro/Pages/MainPage.xaml.cs b/src/IF.Lastfm.Syro/Pages/MainPage.xaml.cs index a23280d..e80604f 100644 --- a/src/IF.Lastfm.Syro/Pages/MainPage.xaml.cs +++ b/src/IF.Lastfm.Syro/Pages/MainPage.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows.Controls; +using System.Windows; +using System.Windows.Controls; using IF.Lastfm.Syro.ViewModels; namespace IF.Lastfm.Syro.Pages diff --git a/src/IF.Lastfm.Syro/Tools/Program.cs b/src/IF.Lastfm.Syro/Tools/ProgressReport.cs similarity index 78% rename from src/IF.Lastfm.Syro/Tools/Program.cs rename to src/IF.Lastfm.Syro/Tools/ProgressReport.cs index aded7d8..6933e70 100644 --- a/src/IF.Lastfm.Syro/Tools/Program.cs +++ b/src/IF.Lastfm.Syro/Tools/ProgressReport.cs @@ -3,10 +3,8 @@ using System.IO; using System.Linq; using System.Net.Http; -using System.Reflection; using System.Text; using HtmlAgilityPack; -using IF.Lastfm.Core.Api.Commands; namespace IF.Lastfm.Syro.Tools { @@ -86,50 +84,7 @@ private static bool HasClass(HtmlNode stay, string classy) } #endregion - - #region Reflect - /// - /// With thanks to Tim Murphy - /// http://stackoverflow.com/a/4529684/268555 - /// - public static IEnumerable FindSubClassesOf(Type type) - { - var typeInfo = type.GetTypeInfo(); - var assembly = typeInfo.Assembly; - return assembly.DefinedTypes.Where(t => t.IsSubclassOf(type)).Select(t => t.AsType()); - } - - /// - /// Reflect on implemented commands - /// - internal static IEnumerable GetImplementedCommands() - { - var types = FindSubClassesOf(typeof(LastAsyncCommandBase)) - .Select(t => t.GetTypeInfo()) - .Where(t => t.IsClass && !t.IsAbstract) - .Select(t => t.AsType()); - var methods = types.Select(GetApiMethodFromCommandType); - - return methods; - } - - private static string GetApiMethodFromCommandType(Type type) - { - var typeInfo = type.GetTypeInfo(); - - // assuming there is only one constructor - var constructor = typeInfo.DeclaredConstructors.First(); - var parameters = constructor.GetParameters(); - var arguments = new object[parameters.Count()]; // to keep reflection happy - - var instance = (LastAsyncCommandBase)Activator.CreateInstance(type, arguments); - - return instance.Method; - } - - #endregion - #region Report internal static void WriteReport(Dictionary> apiGroup, List allImplemented, string path) diff --git a/src/IF.Lastfm.Syro/Tools/Reflektor.cs b/src/IF.Lastfm.Syro/Tools/Reflektor.cs new file mode 100644 index 0000000..a80ddf5 --- /dev/null +++ b/src/IF.Lastfm.Syro/Tools/Reflektor.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using IF.Lastfm.Core.Api.Commands; + +namespace IF.Lastfm.Syro.Tools +{ + public class Reflektor + { + /// + /// With thanks to Tim Murphy + /// http://stackoverflow.com/a/4529684/268555 + /// + public static IEnumerable FindClassesCastableTo(Type type) + { + var typeInfo = type.GetTypeInfo(); + var assembly = typeInfo.Assembly; + return assembly.DefinedTypes.Where(t => type.IsAssignableFrom(t) && t != type).Select(t => t.AsType()); + } + + /// + /// Reflect on implemented commands + /// + internal static IEnumerable GetImplementedCommands() + { + var types = FindClassesCastableTo(typeof(LastAsyncCommandBase)) + .Select(t => t.GetTypeInfo()) + .Where(t => t.IsClass && !t.IsAbstract) + .Select(t => t.AsType()); + + return types; + } + + public static LastAsyncCommandBase CreateCommand(Type type) + { + var typeInfo = type.GetTypeInfo(); + + // assuming there is only one constructor + var constructor = typeInfo.DeclaredConstructors.First(); + var parameters = constructor.GetParameters(); + var arguments = new object[parameters.Count()]; // to keep reflection happy + + var instance = (LastAsyncCommandBase)Activator.CreateInstance(type, arguments); + + return instance; + } + } +} \ No newline at end of file diff --git a/src/IF.Lastfm.Syro/ViewModels/MainViewModel.cs b/src/IF.Lastfm.Syro/ViewModels/MainViewModel.cs index 443dad7..b705e71 100644 --- a/src/IF.Lastfm.Syro/ViewModels/MainViewModel.cs +++ b/src/IF.Lastfm.Syro/ViewModels/MainViewModel.cs @@ -1,13 +1,23 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; -using IF.Common.Metro.Mvvm; +using System.Reflection; +using System.Security.AccessControl; +using IF.Lastfm.Core; +using IF.Lastfm.Core.Api; +using IF.Lastfm.Core.Api.Commands; +using IF.Lastfm.Core.Api.Commands.UserApi; +using IF.Lastfm.Core.Api.Helpers; +using IF.Lastfm.Core.Objects; +using IF.Lastfm.Syro.Helpers; using IF.Lastfm.Syro.Tools; using System.Linq; using System.Threading.Tasks; using System.Windows.Input; +using Newtonsoft.Json; namespace IF.Lastfm.Syro.ViewModels { @@ -18,8 +28,35 @@ internal class MainViewModel : ViewModelBase private List _remainingCommands; private int _apiProgress; private string _reportPath; + private Type _selectedCommandType; + private ObservableCollection> _commandParameters; + private Type _selectedLastObjectType; + private bool _executingCommand; + private Type _selectedResponseType; + private ILastAuth _lastAuth; + private string _commandResult; + private string _commandMethodName; + private string _commandPageNumber; + private string _commandItemCount; private const string ReportFilename = "PROGRESS.md"; + #region Binding properties + + public ICommand GenerateProgressReportCommand { get; private set; } + public ICommand OpenReportCommand { get; private set; } + public ICommand ExecuteSelectedCommandCommand { get; private set; } + + public string CommandResult + { + get { return _commandResult; } + set + { + if (value == _commandResult) return; + _commandResult = value; + OnPropertyChanged(); + } + } + public bool GeneratingProgressReport { get { return _generatingProgressReport; } @@ -64,18 +101,236 @@ public List RemainingCommands } } - public ICommand GenerateProgressReportCommand { get; private set; } - public ICommand OpenReportCommand { get; private set; } + public IEnumerable BaseCommandTypes { get; private set; } - public MainViewModel() + public Type SelectedBaseCommandType { + get { return _selectedCommandType; } + set + { + if (value == _selectedCommandType) return; + + _selectedCommandType = value; + OnPropertyChanged(); + } + } + + public IEnumerable LastObjectTypes { get; private set; } + + public Type SelectedLastObjectType + { + get { return _selectedLastObjectType; } + set + { + if (value == _selectedLastObjectType) return; + _selectedLastObjectType = value; + OnPropertyChanged(); + } + } + + public IEnumerable LastResponseTypes { get; private set; } + + public Type SelectedResponseType + { + get { return _selectedResponseType; } + set + { + if (value == _selectedResponseType) return; + _selectedResponseType = value; + OnPropertyChanged(); + } + } + + public ObservableCollection> CommandParameters + { + get { return _commandParameters; } + set + { + if (Equals(value, _commandParameters)) return; + _commandParameters = value; + OnPropertyChanged(); + } + } + + public bool ExecutingCommand + { + get { return _executingCommand; } + set + { + if (value.Equals(_executingCommand)) return; + _executingCommand = value; + OnPropertyChanged(); + } + } + + public string CommandMethodName + { + get { return _commandMethodName; } + set + { + if (value == _commandMethodName) return; + _commandMethodName = value; + OnPropertyChanged(); + } + } + + public string CommandPageNumber + { + get { return _commandPageNumber; } + set + { + if (value == _commandPageNumber) return; + _commandPageNumber = value; + OnPropertyChanged(); + } + } + + public string CommandItemCount + { + get { return _commandItemCount; } + set + { + if (value == _commandItemCount) return; + _commandItemCount = value; + OnPropertyChanged(); + } + } + + #endregion + + public MainViewModel(ILastAuth lastAuth) + { + _lastAuth = lastAuth; + GenerateProgressReportCommand = new AsyncDelegateCommand(GenerateProgressReport); OpenReportCommand = new DelegateCommand(OpenProgressReport); + ExecuteSelectedCommandCommand = new AsyncDelegateCommand(ExecuteSelectedCommand); var currentDir = AppDomain.CurrentDomain.BaseDirectory; SolutionDir = Path.GetFullPath(currentDir + "../../../../"); // assuming this is running in debug dir + + BaseCommandTypes = new List + { + typeof(DummyGetAsyncCommand<>), + typeof(DummyPostAsyncCommand<>) + }; + LastObjectTypes = Reflektor.FindClassesCastableTo(typeof (ILastfmObject)); + LastResponseTypes = Reflektor.FindClassesCastableTo(typeof (LastResponse)); + + SelectedBaseCommandType = BaseCommandTypes.FirstOrDefault(); + SelectedLastObjectType = LastObjectTypes.FirstOrDefault(); + SelectedResponseType = LastResponseTypes.FirstOrDefault(); + + CommandParameters = new ObservableCollection>(new List> + { + new Pair(), + new Pair(), + new Pair(), + new Pair(), + new Pair() + }); + + CommandMethodName = "album.getInfo"; + CommandPageNumber = "0"; + CommandItemCount = "20"; } - + + private async Task ExecuteSelectedCommand() + { + if (ExecutingCommand) + { + return; + } + + ExecutingCommand = true; + + try + { + // build up the command> + var responseType = SelectedResponseType.MakeGenericType(SelectedLastObjectType); + var genericType = SelectedBaseCommandType.MakeGenericType(responseType); + + if (!_lastAuth.Authenticated) + { + await _lastAuth.GetSessionTokenAsync("tehrikkit", "#facedusk17a"); + } + + var instance = Activator.CreateInstance(genericType, _lastAuth); + + var parameters = CommandParameters + .Where(pair => !string.IsNullOrWhiteSpace(pair.Key) && !string.IsNullOrWhiteSpace(pair.Value)) + .ToDictionary(pair => pair.Key, pair => pair.Value); + + var methodProperty = genericType.GetProperty("Method", BindingFlags.Public | BindingFlags.Instance); + methodProperty.SetValue(instance, CommandMethodName); + + if (SelectedResponseType == typeof(PageResponse<>)) + { + var pageProperty = genericType.GetProperty("Page", BindingFlags.Public | BindingFlags.Instance); + pageProperty.SetValue(instance, int.Parse(CommandPageNumber)); + + var countProperty = genericType.GetProperty("Count", BindingFlags.Public | BindingFlags.Instance); + countProperty.SetValue(instance, int.Parse(CommandItemCount)); + + var addPageParamsMethod = genericType.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).First(m => m.Name == "AddPagingParameters"); + addPageParamsMethod.Invoke(instance, null); + } + + var parametersProperty = genericType.GetProperty("Parameters", + BindingFlags.Public | BindingFlags.Instance); + parametersProperty.SetValue(instance, parameters); + + //test + var command = new GetRecentStationsCommand(_lastAuth, "tehrikkit") + { + Count = 5, + Page = 1 + }; + await command.ExecuteAsync(); + + // execute + var executeMethod = genericType.GetMethods().First(m => m.Name == "ExecuteAsync"); + await (dynamic) executeMethod.Invoke(instance, null); + + + + // cast so we can get the Json response + var dummyCommand = (IDummyCommand) instance; + var jo = dummyCommand.Response; + + var formattedJson = jo.ToString(Formatting.Indented); + + // writeout to file + var filename = string.Format("syro-{0}-{1}.json", jo.Properties().First().Name, + DateTime.Now.ToString("yyMMdd-HHmmss")); + var tempDirPath = Path.GetFullPath(SolutionDir + "tmp/"); + + if (!Directory.Exists(tempDirPath)) + { + Directory.CreateDirectory(tempDirPath); + } + var path = Path.GetFullPath(tempDirPath + filename); + + // write to output directory and launch + using (var fs = new FileStream(path, FileMode.Create)) + { + using (var sw = new StreamWriter(fs)) + { + sw.Write(formattedJson); + } + } + Process.Start(path); + + CommandResult = formattedJson; + } + finally + { + ExecutingCommand = false; + } + } + + #region Progress report + private async Task GenerateProgressReport() { if (GeneratingProgressReport) @@ -95,7 +350,7 @@ await Task.Run(() => } // reflect on Last.fm assembly to find all implemented commands - var allImplemented = ProgressReport.GetImplementedCommands().ToList(); + var allImplemented = Reflektor.GetImplementedCommands().Select(Reflektor.CreateCommand).Select(c => c.Method).ToList(); // generate the markdown _reportPath = Path.GetFullPath(SolutionDir + ReportFilename); @@ -118,11 +373,14 @@ await Task.Run(() => GeneratingProgressReport = false; } + private void OpenProgressReport() { var path = _reportPath ?? Path.GetFullPath(SolutionDir + ReportFilename); Process.Start(path); } + + #endregion } } diff --git a/src/IF.Lastfm.Syro/ViewModels/ViewModelLocator.cs b/src/IF.Lastfm.Syro/ViewModels/ViewModelLocator.cs index baba4a2..f405bc4 100644 --- a/src/IF.Lastfm.Syro/ViewModels/ViewModelLocator.cs +++ b/src/IF.Lastfm.Syro/ViewModels/ViewModelLocator.cs @@ -1,4 +1,5 @@ using GalaSoft.MvvmLight.Ioc; +using IF.Lastfm.Core.Api; using Microsoft.Practices.ServiceLocation; namespace IF.Lastfm.Syro.ViewModels @@ -15,7 +16,9 @@ public class ViewModelLocator public ViewModelLocator() { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); - + + var auth = new LastAuth("a6ab4b9376e54cdb06912bfbd9c1f288", "3aa7202fd1bc6d5a7ac733246cbccc4b"); + SimpleIoc.Default.Register(() => auth); SimpleIoc.Default.Register(); } @@ -23,10 +26,5 @@ public T Get() { return ServiceLocator.Current.GetInstance(); } - - public static void Cleanup() - { - // TODO Clear the ViewModels - } } } \ No newline at end of file diff --git a/src/IF.Lastfm.Syro/packages.config b/src/IF.Lastfm.Syro/packages.config index 248be4a..a69e217 100644 --- a/src/IF.Lastfm.Syro/packages.config +++ b/src/IF.Lastfm.Syro/packages.config @@ -8,4 +8,5 @@ + \ No newline at end of file