コード例 #1
0
        public void CheckAvailability()
        {
            AvailableOptions.Clear();

            foreach (IAccomodation accomodation in _accomodationList)
            {
                if (accomodation.HasSameLocationAs(_selectedLocation))
                {
                    if (accomodation.HasRoomsAvailableIn(_reservation.ReservationPeriod))
                    {
                        Option option = new Option(accomodation, accomodation.GetBestOptionFor(_reservation));
                        option.ComputeTotalPriceFor(_reservation.ReservationPeriod);
                        AvailableOptions.Add(option);
                    }
                }
            }
        }
コード例 #2
0
        public void ShowBookingVoucherView()
        {
            BookingVoucherView      bookingVoucherView      = new BookingVoucherView();
            BookingVoucherViewModel bookingVoucherViewModel = new BookingVoucherViewModel();

            if (_roomsToReserve.Count != 0)
            {
                ObservableCollection <IRoom> newList = new ObservableCollection <IRoom>();
                foreach (IRoom room in _roomsToReserve)
                {
                    newList.Add(room);
                }
                _selectedOption.RoomList = newList;
            }

            bookingVoucherViewModel.Reservation = new Reservation(_reservation.Owner, _selectedOption.Hotel, _reservation.ReservationPeriod, _reservation.NumberOfPersons, _selectedOption);
            bookingVoucherView.DataContext      = bookingVoucherViewModel;

            bookingVoucherView.Show();
            Reservation = new Reservation();

            AvailableOptions.Clear();
            RoomsToReserve.Clear();
        }
コード例 #3
0
        private async void OnUpdateOptions()
        {
            try
            {
                EnableButtons(false);

                var workingFolder = Path.Combine(Config.SourceFolder, "v8");
                var configFolder  = (Application.Current as App).ConfigFolder;
                var genFolder     = Path.Combine(configFolder, "Downloads", "out.gn", "defaults");
                var argsFileName  = Path.Combine(configFolder, "Downloads", "gn_defaults.txt");

                if (!Directory.Exists(workingFolder))
                {
                    MessageBox.Show($"You must select an existing V8 source folder for the depot_tools to be able to produce a list "
                                    + "of available compiler options", $"V8 folder not found - '{workingFolder}'");
                    StatusText = "Updating build options failed";
                    return;
                }
                if (Directory.Exists(genFolder))
                {
                    try
                    {
                        FileSystem.DeleteDirectory(genFolder, UIOption.AllDialogs, RecycleOption.SendToRecycleBin);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show($"Cannot delete '{genFolder}'; is that folder open in another program?"
                                        , $"Building V8 failed");
                        StatusText = $"failed to delete '{genFolder}'";
                        return;
                    }
                }

                var batch = new BatchFile
                {
                    WorkingDirectory = workingFolder,
                    Model            = this,
                    Title            = $"retrieving the list of available build options",
                };
                if (!CheckPython(batch.PythonFileName))
                {
                    return;
                }

                // batch.Commands.Add($"call python tools\\dev\\v8gen.py gen -b {Config.BuildConfiguration} \"{genFolder}\" --no-goma");
                var gnFileName = Path.Combine(Config.DepotToolsFolder, "gn.py");
                batch.Commands.Add($"\"{batch.PythonFileName}\" \"{gnFileName}\" gen \"{genFolder}\"");
                batch.Commands.Add($"\"{batch.PythonFileName}\" \"{gnFileName}\" args \"{genFolder}\" --list >{argsFileName}");
                StatusText = batch.Title;
                StatusText = await batch.Run();

                //var installer = CreateInstaller();
                //StatusText = "Extracting build options";
                //installer.WorkingDirectory = Path.Combine(Config.SourceFolder, "v8");

                //installer.Arguments = $"/k title Generating a list of build options & gn gen \"{genFolder}\" & gn args \"{genFolder}\" --list >{argsFileName}";
                //await Task.Run(() => Process.Start(installer).WaitForExit());

                var existingOptions = new Dictionary <string, BuildOption>(StringComparer.OrdinalIgnoreCase);
                foreach (var option in Config.BuildOptions)
                {
                    existingOptions[option.Name] = option;
                }
                AvailableOptions.Clear();
                SelectedOptions.Clear();

                StatusText = "Parsing build options";
                Config.BuildOptions.Clear();
                var               lines              = File.ReadAllLines(argsFileName);
                BuildOption       currentOption      = null;
                OptionParserState state              = OptionParserState.None;
                StringBuilder     descriptionBuilder = null;
                for (var ii = 0; ii < lines.Length; ++ii)
                {
                    var line = lines[ii];
                    switch (state)
                    {
                    case OptionParserState.None:
                    case OptionParserState.Name:
                        descriptionBuilder = new StringBuilder();
                        var name = line.Trim();
                        if (existingOptions.TryGetValue(name, out currentOption))
                        {
                            existingOptions.Remove(name);
                        }
                        else
                        {
                            currentOption = new Configuration.BuildOption
                            {
                                Name = line
                            };
                        }
                        if (currentOption.Selected)
                        {
                            SelectedOptions.Add(currentOption);
                        }
                        else
                        {
                            AvailableOptions.Add(currentOption);
                        }
                        Config.BuildOptions.Add(currentOption);
                        state = OptionParserState.Current;
                        break;

                    case OptionParserState.Current:
                        currentOption.Default = line.Split('=')[1].Trim();
                        state = OptionParserState.From;
                        break;

                    case OptionParserState.From:
                        state = OptionParserState.Blank;
                        break;

                    case OptionParserState.Blank:
                        state = OptionParserState.Description;
                        break;

                    case OptionParserState.Description:
                        if (!string.IsNullOrEmpty(line) && line[0] != ' ')
                        {
                            --ii;       // Reparse this line, it's the next name
                            currentOption.Description = descriptionBuilder.ToString().Trim();
                            state = OptionParserState.Name;
                        }
                        else
                        {
                            descriptionBuilder.Append(' ');
                            descriptionBuilder.Append(line.Trim());
                        }
                        break;
                    }
                }
                if (currentOption != null && descriptionBuilder != null && (descriptionBuilder.Length > 0))
                {
                    currentOption.Description = descriptionBuilder.ToString();
                }
                StatusText = "Ready";
            }
            finally
            {
                EnableButtons(true);
            }
        }