|
@@ -1,37 +1,33 @@
|
|
import { injectable, inject } from 'inversify';
|
|
import { injectable, inject } from 'inversify';
|
|
import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
|
|
import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
|
|
|
|
|
|
-import { TCustomNodesFactory } from '../../types/container/TCustomNodesFactory';
|
|
|
|
-
|
|
|
|
import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode';
|
|
import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode';
|
|
|
|
+import { IInitializable } from '../../interfaces/IInitializable';
|
|
import { IOptions } from '../../interfaces/options/IOptions';
|
|
import { IOptions } from '../../interfaces/options/IOptions';
|
|
import { IStackTraceData } from '../../interfaces/stack-trace-analyzer/IStackTraceData';
|
|
import { IStackTraceData } from '../../interfaces/stack-trace-analyzer/IStackTraceData';
|
|
|
|
|
|
-import { ConsoleOutputCustomNodesFactory } from '../../custom-nodes/console-output-nodes/factory/ConsoleOutputCustomNodesFactory';
|
|
|
|
-import { DebugProtectionCustomNodesFactory } from '../../custom-nodes/debug-protection-nodes/factory/DebugProtectionCustomNodesFactory';
|
|
|
|
-import { DomainLockCustomNodesFactory } from '../../custom-nodes/domain-lock-nodes/factory/DomainLockCustomNodesFactory';
|
|
|
|
|
|
+import { CustomNodesFactories } from '../../enums/container/CustomNodesFactories';
|
|
|
|
+
|
|
import { MapStorage } from '../MapStorage';
|
|
import { MapStorage } from '../MapStorage';
|
|
-import { SelfDefendingCustomNodesFactory } from '../../custom-nodes/self-defending-nodes/factory/SelfDefendingCustomNodesFactory';
|
|
|
|
-import { StringArrayCustomNodesFactory } from '../../custom-nodes/string-array-nodes/factory/StringArrayCustomNodesFactory';
|
|
|
|
-import { IInitializable } from '../../interfaces/IInitializable';
|
|
|
|
|
|
+import { TCustomNodesFactoriesFactory } from '../../types/container/TCustomNodesFactoriesFactory';
|
|
|
|
|
|
@injectable()
|
|
@injectable()
|
|
export class CustomNodesStorage extends MapStorage <ICustomNode> implements IInitializable {
|
|
export class CustomNodesStorage extends MapStorage <ICustomNode> implements IInitializable {
|
|
/**
|
|
/**
|
|
- * @type {TCustomNodesFactory[]}
|
|
|
|
|
|
+ * @type {CustomNodesFactories[]}
|
|
*/
|
|
*/
|
|
- private static readonly customNodesFactories: TCustomNodesFactory[] = [
|
|
|
|
- DomainLockCustomNodesFactory,
|
|
|
|
- SelfDefendingCustomNodesFactory,
|
|
|
|
- ConsoleOutputCustomNodesFactory,
|
|
|
|
- DebugProtectionCustomNodesFactory,
|
|
|
|
- StringArrayCustomNodesFactory
|
|
|
|
|
|
+ private static readonly customNodesFactoriesList: CustomNodesFactories[] = [
|
|
|
|
+ CustomNodesFactories.ConsoleOutputCustomNodesFactory,
|
|
|
|
+ CustomNodesFactories.DebugProtectionCustomNodesFactory,
|
|
|
|
+ CustomNodesFactories.DomainLockCustomNodesFactory,
|
|
|
|
+ CustomNodesFactories.SelfDefendingCustomNodesFactory,
|
|
|
|
+ CustomNodesFactories.StringArrayCustomNodesFactory
|
|
];
|
|
];
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @type {boolean}
|
|
|
|
|
|
+ * @type {TCustomNodesFactoriesFactory}
|
|
*/
|
|
*/
|
|
- public initialized: boolean = false;
|
|
|
|
|
|
+ private readonly customNodesFactoriesFactory: TCustomNodesFactoriesFactory;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @type {IOptions}
|
|
* @type {IOptions}
|
|
@@ -39,29 +35,28 @@ export class CustomNodesStorage extends MapStorage <ICustomNode> implements IIni
|
|
private readonly options: IOptions;
|
|
private readonly options: IOptions;
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * @param customNodesFactoriesFactory
|
|
* @param options
|
|
* @param options
|
|
*/
|
|
*/
|
|
- constructor (@inject(ServiceIdentifiers.IOptions) options: IOptions) {
|
|
|
|
|
|
+ constructor (
|
|
|
|
+ @inject(ServiceIdentifiers['Factory<ICustomNodesFactory>']) customNodesFactoriesFactory: TCustomNodesFactoriesFactory,
|
|
|
|
+ @inject(ServiceIdentifiers.IOptions) options: IOptions
|
|
|
|
+ ) {
|
|
super();
|
|
super();
|
|
|
|
|
|
|
|
+ this.customNodesFactoriesFactory = customNodesFactoriesFactory;
|
|
this.options = options;
|
|
this.options = options;
|
|
}
|
|
}
|
|
|
|
|
|
- public checkInitialization (): void {
|
|
|
|
- if (!this.initialized) {
|
|
|
|
- throw new Error(`\`CustomNodesStorage\` should be initialized first by calling \`initialize\` method!`);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* @param stackTraceData
|
|
* @param stackTraceData
|
|
*/
|
|
*/
|
|
public initialize (stackTraceData: IStackTraceData[]): void {
|
|
public initialize (stackTraceData: IStackTraceData[]): void {
|
|
const customNodes: [string, ICustomNode][] = [];
|
|
const customNodes: [string, ICustomNode][] = [];
|
|
|
|
|
|
- CustomNodesStorage.customNodesFactories.forEach((customNodesFactoryConstructor: TCustomNodesFactory) => {
|
|
|
|
- const customNodesFactory: Map <string, ICustomNode> | undefined = new customNodesFactoryConstructor(
|
|
|
|
- this.options
|
|
|
|
|
|
+ CustomNodesStorage.customNodesFactoriesList.forEach((customNodesFactoryName: CustomNodesFactories) => {
|
|
|
|
+ const customNodesFactory: Map <string, ICustomNode> | undefined = this.customNodesFactoriesFactory(
|
|
|
|
+ customNodesFactoryName
|
|
).initializeCustomNodes(stackTraceData);
|
|
).initializeCustomNodes(stackTraceData);
|
|
|
|
|
|
if (!customNodesFactory) {
|
|
if (!customNodesFactory) {
|
|
@@ -72,7 +67,6 @@ export class CustomNodesStorage extends MapStorage <ICustomNode> implements IIni
|
|
});
|
|
});
|
|
|
|
|
|
this.storage = new Map <string, ICustomNode> (customNodes);
|
|
this.storage = new Map <string, ICustomNode> (customNodes);
|
|
- this.initialized = true;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -80,8 +74,6 @@ export class CustomNodesStorage extends MapStorage <ICustomNode> implements IIni
|
|
* @returns {ICustomNode}
|
|
* @returns {ICustomNode}
|
|
*/
|
|
*/
|
|
public get (key: string | number): ICustomNode {
|
|
public get (key: string | number): ICustomNode {
|
|
- this.checkInitialization();
|
|
|
|
-
|
|
|
|
return super.get(key);
|
|
return super.get(key);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -90,8 +82,6 @@ export class CustomNodesStorage extends MapStorage <ICustomNode> implements IIni
|
|
* @returns {string | number | null}
|
|
* @returns {string | number | null}
|
|
*/
|
|
*/
|
|
public getKeyOf (value: ICustomNode): string | number | null {
|
|
public getKeyOf (value: ICustomNode): string | number | null {
|
|
- this.checkInitialization();
|
|
|
|
-
|
|
|
|
return super.getKeyOf(value);
|
|
return super.getKeyOf(value);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -99,8 +89,6 @@ export class CustomNodesStorage extends MapStorage <ICustomNode> implements IIni
|
|
* @returns {number}
|
|
* @returns {number}
|
|
*/
|
|
*/
|
|
public getLength (): number {
|
|
public getLength (): number {
|
|
- this.checkInitialization();
|
|
|
|
-
|
|
|
|
return super.getLength();
|
|
return super.getLength();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -108,8 +96,6 @@ export class CustomNodesStorage extends MapStorage <ICustomNode> implements IIni
|
|
* @returns {Map <string | number, ICustomNode>}
|
|
* @returns {Map <string | number, ICustomNode>}
|
|
*/
|
|
*/
|
|
public getStorage (): Map <string | number, ICustomNode> {
|
|
public getStorage (): Map <string | number, ICustomNode> {
|
|
- this.checkInitialization();
|
|
|
|
-
|
|
|
|
return super.getStorage();
|
|
return super.getStorage();
|
|
}
|
|
}
|
|
}
|
|
}
|