File

projects/wms-framework/src/lib/regionsframework/RegionBehavior.ts

Description

Region behavior base implementation

Implements

IRegionBehavior

Index

Properties
Methods
Accessors

Properties

IsAttached
Type : boolean

Value indicating that the region behavior is attached

region
Type : IRegion

Methods

Attach
Attach()

Attaches the behavior to the region

Returns : void
Abstract OnAttach
OnAttach()

Action executed when the behavior is attached to a region

Returns : void

Accessors

Region
getRegion()

Gets the region attached to the behavior

setRegion(value: IRegion)

Sets the region attached to the behavior

Parameters :
Name Type Optional
value IRegion No
Returns : void
import { IRegionBehavior } from './IRegionBehavior';
import { IRegion } from './IRegion';
import { InvalidOperationException } from '../baseframework';

/**
 * Region behavior base implementation
 *
 * @export
 * @abstract
 * @class RegionBehavior
 * @implements {IRegionBehavior}
 * @wType Microsoft.Practices.Prism.Regions.RegionBehavior
 */
export abstract class RegionBehavior implements IRegionBehavior {
  /**
   * Value indicating that the region behavior is attached
   *
   * @type {boolean}
   * @memberof RegionBehavior
   */
  IsAttached: boolean;

  /**
   * The attached region to the behavior
   *
   * @type {IRegion}
   * @memberof RegionBehavior
   */
  #region: IRegion;

  /**
   * Gets the region attached to the behavior
   *
   * @memberof RegionBehavior
   */
  get Region() {
    return this.#region;
  }

  /**
   * Sets the region attached to the behavior
   *
   * @memberof RegionBehavior
   */
  set Region(value: IRegion) {
    if (this.IsAttached) {
      throw new InvalidOperationException(
        'Region Behavior cannot be set after attach'
      );
    }
    this.#region = value;
  }

  /**
   * Attaches the behavior to the region
   *
   * @memberof RegionBehavior
   */
  Attach(): void {
    if (this.#region == null) {
      throw new InvalidOperationException(
        'Region Behavior attach cannot be call with null region '
      );
    }
    this.IsAttached = true;
    this.OnAttach();
  }

  /**
   * Action executed when the behavior is attached to a region
   *
   * @abstract
   * @memberof RegionBehavior
   */
  abstract OnAttach(): void;
}

result-matching ""

    No results matching ""