コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: andycb/BugView
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        /// <param name="windowService">
        /// The window service
        /// </param>
        /// <param name="addinService">
        /// The add-in service
        /// </param>
        /// <param name="settingsService">
        /// The settings service
        /// </param>
        public MainViewModel(IWindowService windowService, IAddinService addinService, ISettingsService settingsService)
        {
            this.windowService = windowService;

            var projects = settingsService.GetProjects();
            var projectModel = projects.FirstOrDefault();

            var tt = addinService.TaskTrackers.First();
            var qs = tt.GenerateQuerySettings();

            if (!projects.Any())
            {
                projectModel = new ProjectModel("Demo project", tt.Id);
                var ss = new SecureString();
                ss.AppendChar('H');
                ss.AppendChar('e');
                ss.AppendChar('l');
                ss.AppendChar('l');
                ss.AppendChar('o');

                var testSettings = new Dictionary<string, SecureString>
                {
                    { "SomeKey1", ss },
                    { "SomeKey2", ss }
                };

                var projectSettings1 = new SettingsModel(projectModel.InternalUrn, testSettings);
                settingsService.SaveProject(projectModel, projectSettings1);
            }

            var projectSettings2 = settingsService.GetProjectSettings(projectModel);
            this.Tasks = new ObservableCollection<ITaskModel>(tt.GetAssignedToUser(projectModel, projectSettings2));

            settingsService.SaveProject(projectModel);
        }