/* * Returns a reference to a new PersonComponent identical in content * to calling instance, except unwraped from the PersonDecorator * passed as a parameter (or the to the Booking itself if it is not * decorated at all). */ public override PersonComponent Undecorate(PersonDecorator reference) { if (this == reference) { return(decoratedComponent); } /* Short circuit method if the decorator to remove is the * last one added. */ List <PersonDecorator> references; PersonComponent result = this.Unwrap(out references); foreach (PersonDecorator decorator in references) { if (decorator != reference) { decorator.decoratedComponent = result; result = decorator; } } return(result); }
/* * Returns the PersonComponent itself. */ public virtual PersonComponent Undecorate(PersonDecorator reference) { return(this); }