projects/wms-framework/src/lib/regionsframework/RegionAdapterMappings.ts
Collection of region adapter mappings
Properties |
|
Methods |
|
Private mappings |
Type : SimpleDictionary<string | IRegionAdapter>
|
Default value : new SimpleDictionary()
|
getAdapter | ||||||
getAdapter(type: RuntimeTypeInfo)
|
||||||
Returns a registered adapter for the given type
Parameters :
Returns :
IRegionAdapter
{IRegionAdapter} |
Public RegisterMapping | |||||||||
RegisterMapping(controlType: RuntimeTypeInfo, adapter: IRegionAdapter)
|
|||||||||
Register a new adapter
Parameters :
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;
}
}