Example #1
0
        public MainViewModel(UserSettings userSettings, IEnumerable<ClientVersion> clientVersions, IDialogService dialogService)
            : base(App.ApplicationName, dialogService)
        {
            if (userSettings == null)
                throw new ArgumentNullException("userSettings");

            if (clientVersions == null)
                throw new ArgumentNullException("clientVersions");

            if (dialogService == null)
                throw new ArgumentNullException("dialogService");

            this.userSettings = userSettings;
            this.clientVersions = clientVersions;

            // Create user settings view model
            this.userSettingsViewModel = new UserSettingsViewModel(userSettings);

            // Create client version view model for each client settings object (via LINQ projection)
            var viewModels = from v in clientVersions
                             orderby v.VersionCode descending
                             select new ClientVersionViewModel(v);

            this.clientVersionViewModels = new ObservableCollection<ClientVersionViewModel>(viewModels);
        }