Пример #1
0
        public MainViewModel(ILastAuth lastAuth)
        {
            _lastAuth = lastAuth;

            GenerateProgressReportCommand = new AsyncDelegateCommand(GenerateProgressReport);
            OpenReportCommand             = new DelegateCommand(OpenProgressReport);
            ExecuteSelectedCommandCommand = new AsyncDelegateCommand(ExecuteSelectedCommand);
            DeleteConfigCommand           = new DelegateCommand(() =>
            {
                if (_configPath != null && File.Exists(_configPath))
                {
                    File.Delete(_configPath);
                }

                InitialiseState();
            });

            var currentDir = AppDomain.CurrentDomain.BaseDirectory;

            SolutionDir = Path.GetFullPath(currentDir + "../../../../"); // assuming this is running in debug dir
            _configPath = Path.GetFullPath(SolutionDir + SYRO_CONFIG_FILENAME);

            BaseCommandTypes = new List <Type>
            {
                typeof(DummyGetAsyncCommand <>),
                typeof(DummyPostAsyncCommand <>)
            };
            LastObjectTypes   = Reflektor.FindClassesCastableTo(typeof(ILastfmObject));
            LastResponseTypes = Reflektor.FindClassesCastableTo(typeof(LastResponse));

            InitialiseState();

            Application.Current.Exit += OnAppExit;
        }
Пример #2
0
        private async Task GenerateProgressReport()
        {
            if (GeneratingProgressReport)
            {
                return;
            }

            GeneratingProgressReport = true;

            await Task.Run(() =>
            {
                // scrape Last.fm API documentation
                var apiGroup = ProgressReport.GetApiMethods();
                if (apiGroup == null)
                {
                    return;
                }

                // reflect on Last.fm assembly to find all implemented commands
                var allImplemented = Reflektor.GetImplementedCommands().Select(Reflektor.CreateCommand).Select(c => c.Method).ToList();

                // generate the markdown
                _reportPath = Path.GetFullPath(SolutionDir + ReportFilename);
                ProgressReport.WriteReport(apiGroup, allImplemented, _reportPath);

                // ui, duplicating code but w/e
                ApiProgress = (int)ProgressReport.GetPercentage(apiGroup, allImplemented);

                var notimp = new List <string>();
                foreach (var group in apiGroup)
                {
                    var implemented    = allImplemented.Where(m => m.StartsWith(group.Key.ToLowerInvariant(), StringComparison.Ordinal)).ToList();
                    var notImplemented = group.Value.Except(implemented).ToList();

                    notimp.AddRange(notImplemented);
                }

                RemainingCommands = notimp;
            });

            GeneratingProgressReport = false;
        }
Пример #3
0
        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 <Type>
            {
                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 <Pair <string, string> >(new List <Pair <string, string> >
            {
                new Pair <string, string>(),
                new Pair <string, string>(),
                new Pair <string, string>(),
                new Pair <string, string>(),
                new Pair <string, string>()
            });

            CommandMethodName = "album.getInfo";
            CommandPageNumber = "0";
            CommandItemCount  = "20";
        }