コード例 #1
0
 /*
  * Updates properties of a given EveningMeal.
  */
 public void UpdateEveningMeal(BookingDecorator reference,
                               String newDietRequirements)
 {
     CurrentBook = CurrentBook.Undecorate(reference);
     CurrentBook = bFact.AddEveningMeal(CurrentBook,
                                        newDietRequirements);
 }
コード例 #2
0
 /*
  * Updates properties of a given Breakfast.
  */
 public void UpdateBreakfast(BookingDecorator reference,
                             String newDietRequirements)
 {
     CurrentBook = CurrentBook.Undecorate(reference);
     CurrentBook = bFact.AddBreakfast(CurrentBook,
                                      newDietRequirements);
 }
コード例 #3
0
 /*
  * Updates properties of a given CarHire.
  */
 public void UpdateCarHire(BookingDecorator reference,
                           String newDriverName,
                           DateTime newStart,
                           DateTime newEnd)
 {
     CurrentBook = CurrentBook.Undecorate(reference);
     CurrentBook = bFact.AddCarHire(CurrentBook,
                                    newDriverName,
                                    newStart,
                                    newEnd);
 }
        // METHODS:

        /*
         * Constructor, the index passed must be the index in the current
         * booking's decoration stack as returned by
         * ModelFacade.GetCurrentExtras()) or -1 for a new extra.
         */
        public WindowBreakfastDetails(ModelFacade mFacade,
                                      BookingDecorator instance)
        {
            this.mFacade   = mFacade;
            this.breakfast = instance;
            InitializeComponent();

            if (this.breakfast != null)
            {
                txtDietRequirements.Text
                    = ((Breakfast)instance).GetDietRequirements();
            }
            else
            {
                txtDietRequirements.Text = String.Empty;
            }
        }
コード例 #5
0
        // METHODS:

        /*
         * Constructor, the index passed must be the index in the current
         * booking's decoration stack index as returned by
         * ModelFacade.GetCurrentExtras()) or -1 for a new extra.
         */
        public WindowEveningMealDetails(ModelFacade mFacade,
                                        BookingDecorator instance)
        {
            this.mFacade     = mFacade;
            this.eveningMeal = instance;
            InitializeComponent();

            if (this.eveningMeal != null)
            {
                txtDietRequirements.Text
                    = ((EveningMeal)instance).GetDietRequirements();
            }
            else
            {
                txtDietRequirements.Text = String.Empty;
            }
        }
コード例 #6
0
        // METHODS:

        /*
         * Constructor, the index passed must be the index in the current
         * booking's decoration stack index as returned by
         * ModelFacade.GetCurrentExtras()) or -1 for a new extra.
         */
        public WindowCarHireDetails(ModelFacade mFacade,
                                    BookingDecorator instance)
        {
            this.mFacade = mFacade;
            this.carHire = instance;
            InitializeComponent();

            if (this.carHire != null)
            {
                DateTime start;
                DateTime end;
                ((CarHire)instance).GetHireDates(out start, out end);
                dtpStart.SelectedDate = start;
                dtpEnd.SelectedDate   = end;

                txtDriverName.Text = ((CarHire)instance).GetDriverName();
            }
            else
            {
                txtDriverName.Text = String.Empty;
            }
        }
        /*
         * Returns a reference to a new BookingComponent identical in content
         * to calling instance, except unwraped from the BookingDecorator
         * passed as a parameter (or the to the Booking itself if it is not
         * decorated at all).
         */
        public override BookingComponent Undecorate(BookingDecorator reference)
        {
            if (this == reference)
            {
                return(decoratedComponent);
            }

            /* Short circuit method if the decorator to remove is the
             * last one added.
             */
            List <BookingDecorator> references;
            BookingComponent        result = this.Unwrap(out references);

            foreach (BookingDecorator decorator in references)
            {
                if (decorator != reference)
                {
                    decorator.decoratedComponent = result;
                    result = decorator;
                }
            }

            return(result);
        }
コード例 #8
0
 /*
  * Returns the BookingComponent itself.
  */
 public virtual BookingComponent Undecorate(BookingDecorator reference)
 {
     return(this);
 }