File

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

Description

Collection of region adapter mappings

Index

Properties
Methods

Properties

Private mappings
Type : SimpleDictionary<string | IRegionAdapter>
Default value : new SimpleDictionary()

Methods

getAdapter
getAdapter(type: RuntimeTypeInfo)

Returns a registered adapter for the given type

Parameters :
Name Type Optional
type RuntimeTypeInfo No
Returns : IRegionAdapter

{IRegionAdapter}

Public RegisterMapping
RegisterMapping(controlType: RuntimeTypeInfo, adapter: IRegionAdapter)

Register a new adapter

Parameters :
Name Type Optional
controlType RuntimeTypeInfo No
adapter IRegionAdapter No
Returns : void
import { RuntimeTypeInfo } from '../baseframework/ReflectionSupport';
import { IRegionAdapter } from './IRegionAdapter';
import { SimpleDictionary } from '../baseframework';

/**
 *  Collection of region adapter mappings
 *
 * @export
 * @class RegionAdapterMappings
 * @wType Microsoft.Practices.Prism.Regions.RegionAdapterMappings
 */
export class RegionAdapterMappings {
  private mappings: SimpleDictionary<string, IRegionAdapter> =
    new SimpleDictionary();

  /**
   *  Register a new adapter
   *
   * @param {RuntimeTypeInfo} controlType
   * @param {IRegionAdapter} adapter
   * @memberof RegionAdapterMappings
   */
  public RegisterMapping(
    controlType: RuntimeTypeInfo,
    adapter: IRegionAdapter
  ): void {
    this.mappings.addEntry(controlType.FullName, adapter);
  }

  /**
   *  Returns a registered adapter for the given type
   *
   * @param {string} typeName
   * @return {*}  {IRegionAdapter}
   * @memberof RegionAdapterMappings
   * @wMethod GetMapping
   */
  getAdapter(type: RuntimeTypeInfo): IRegionAdapter {
    var currentType = type;
    while (currentType != null) {
      if (this.mappings.containsKey(currentType.FullName)) {
        return this.mappings.getItem(currentType.FullName);
      }
      currentType = currentType.BaseType;
    }
    return null;
  }
}

result-matching ""

    No results matching ""