projects/wms-framework/src/lib/regionsframework/RegionAdapterBase.ts
        
RegionAdapterBase abstract class.
                        Properties | 
                
                        Methods | 
                
                        
  | 
                
constructor(factory: IRegionBehaviorFactory)
                     | 
                ||||||
| 
                             
                                    Parameters :
                                     
                    
  | 
                
| RegionBehaviorFactory | 
                        Type :         IRegionBehaviorFactory
                     | 
                
| Protected Abstract Adapt | |||||||||
                    
                    Adapt(region: IRegion, regionTarget: T)
                 | 
            |||||||||
| 
                     
                        Parameters :
                         
                    
 
                        Returns :          
                    void
                     | 
            
| Protected AttachDefaultBehaviors | |||||||||
                    
                    AttachDefaultBehaviors(region: IRegion, regionTarget: T)
                 | 
            |||||||||
| 
                     Attach defaults behavior to region 
                        Parameters :
                         
                    
 
                        Returns :          
                    void
                     | 
            
| Protected Abstract CreateRegion | 
                    
                    CreateRegion()
                 | 
            
| 
                     
                        Returns :          
                IRegion
                     | 
            
| Initialize | 
Initialize(regionTarget: object, regionName: string)
                 | 
            
| 
                    
                     
                        Returns :          
                    IRegion
                     | 
            
| Public AttachBehaviors | 
                    
                    AttachBehaviors(region: IRegion, target: any)
                 | 
            
| 
                     Inherited from          
                RegionAdapterBaseUnTyped
 | 
            
| 
                         Defined in          
                RegionAdapterBaseUnTyped:23
 | 
            
| 
                    
                     
                        Returns :          
                    void
                     | 
            
import { ArgumentNullException } from '../baseframework';
import { IRegion } from './IRegion';
import { IRegionAdapter } from './IRegionAdapter';
import { IRegionBehaviorFactory } from './IRegionBehaviorFactory';
export class RegionAdapterBaseUnTyped {
  public AttachBehaviors(region: IRegion, target: any) {}
}
/**
 * RegionAdapterBase abstract class.
 *
 * @export
 * @abstract
 * @class RegionAdapterBase
 * @extends {RegionAdapterBaseUnTyped}
 * @implements {IRegionAdapter}
 * @template T
 * @wType Microsoft.Practices.Prism.Regions.RegionAdapterBase`1
 */
export abstract class RegionAdapterBase<T>
  extends RegionAdapterBaseUnTyped
  implements IRegionAdapter
{
  RegionBehaviorFactory: IRegionBehaviorFactory;
  constructor(factory: IRegionBehaviorFactory) {
    super();
    this.RegionBehaviorFactory = factory;
  }
  Initialize(regionTarget: object, regionName: string): IRegion {
    if (regionName == null) {
      throw new ArgumentNullException('regionName');
    }
    const region = this.CreateRegion();
    region.Name = regionName;
    this.Adapt(region, regionTarget as any);
    this.AttachBehaviors(region, regionTarget);
    this.AttachDefaultBehaviors(region, <any>regionTarget);
    return region;
  }
  protected abstract CreateRegion(): IRegion;
  protected abstract Adapt(region: IRegion, regionTarget: T): void;
  /**
   * Attach defaults behavior to region
   *
   * @protected
   * @param {IRegion} region
   * @param {T} regionTarget
   * @memberof RegionAdapterBase
   */
  protected AttachDefaultBehaviors(region: IRegion, regionTarget: T): void {
    if (region == null) {
      throw new ArgumentNullException('region');
    }
    if (regionTarget == null) {
      throw new ArgumentNullException('regionTarget');
    }
    const behaviorFactory = this.RegionBehaviorFactory;
    if (behaviorFactory != null) {
      for (const behaviorKey of behaviorFactory) {
        let behavior = behaviorFactory.CreateFromKey(behaviorKey);
        region.Behaviors.Add(behaviorKey, behavior);
      }
    }
  }
}