/// <summary>
        /// Creates the main view model
        /// </summary>
        /// <returns></returns>
        public static void Update()
        {
            var viewmodel         = ServiceLocator.Get <MainWindowViewModel>();
            var configuration     = ServiceLocator.Get <IConfiguration>();
            var localizerRegistry = ServiceLocator.Get <ILocalizerRegistry>();

            var path = configuration.RecentLocalizedPaths.Any()
                ? configuration.RecentLocalizedPaths.FirstOrDefault()
                : string.Empty;

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            var solutionLocalizer = localizerRegistry.CreateLocalizer <SolutionInfo>();
            var solutions         = solutionLocalizer.GetItems(new DirectoryInfo(path));

            viewmodel.Projects.Clear();

            foreach (var solution in solutions)
            {
                foreach (var project in solution.Projects)
                {
                    var nuspecViewModel = new NuspecViewModel()
                    {
                        Version = project.NuspecVersion?.Version ?? string.Empty,
                        File    = project.NuspecVersion?.File.FullName ?? string.Empty
                    };

                    var assemblyInfoViewModel = new AssemblyInfoViewModel()
                    {
                        Version = project.AssemblyInfoVersion?.Version ?? string.Empty,
                        File    = project.AssemblyInfoVersion?.File.FullName ?? string.Empty
                    };

                    viewmodel.Projects.Add(new ProjectViewModel
                    {
                        Name = project.Name,
                        AssemblyInfoVersion = assemblyInfoViewModel,
                        NuspecVersion       = nuspecViewModel,
                        Solution            = new SolutionViewModel()
                        {
                            Name = solution.Name
                        }
                    });
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectViewModel"/> class.
        /// </summary>
        public ProjectViewModel()
        {
            Solution            = new SolutionViewModel();
            NuspecVersion       = new NuspecViewModel();
            AssemblyInfoVersion = new AssemblyInfoViewModel();

            //Commands
            IncreaseMajorVersionCommand    = new IncreaseMajorVersionCommand();
            IncreaseMinorVersionCommand    = new IncreaseMinorVersionCommand();
            IncreaseRevisionVersionCommand = new IncreaseRevisionVersionCommand();
            DecreaseMajorVersionCommand    = new DecreaseMajorVersionCommand();
            DecreaseMinorVersionCommand    = new DecreaseMinorVersionCommand();
            DecreaseRevisionVersionCommand = new DecreaseRevisionVersionCommand();
            ToggleBuildVersionCommand      = new ToggleBuildVersionCommand();
        }