123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- export default class ConfProxy<T> {
- static getKey(args: string[]): string {
- let out = ""
- args.forEach(element => {
- out += element
- out += "_"
- });
- return out
- }
- static setKey(target: any, args: string[]): string {
- let out = ""
- args.forEach(element => {
- out += target[element]
- out += "_"
- });
- return out
- }
- pool: { [key: string]: T } = {}
- name:string = ""
- constructor(xlsname:string,conf: T[], ...args: string[]) {
- this.name = xlsname
- conf.forEach(element => {
- this.pool[ConfProxy.setKey(element, args)] = element
- });
- }
-
- getItem(...args: string[]): T | null {
- return this.pool[ConfProxy.getKey(args)]
- }
- }
- export class ConfListProxy<T> {
- pool: { [key: string]: T[] } = {}
- name:string = ""
- constructor(xlsname:string,conf: T[], ...args: string[]) {
- this.name = xlsname
- conf.forEach(element => {
- let key = ConfProxy.setKey(element, args)
- if (this.pool[key] == null) {
- this.pool[key] = []
- }
- this.pool[key].push(element)
- });
- }
- getItemList(...args: string[]): T[] | null {
- return this.pool[ConfProxy.getKey(args)]
- }
- }
|