DebugProtectionFunctionIntervalNode.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { inject, injectable, } from 'inversify';
  2. import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
  3. import * as format from 'string-template';
  4. import { TStatement } from '../../types/node/TStatement';
  5. import { IOptions } from '../../interfaces/options/IOptions';
  6. import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
  7. import { initializable } from '../../decorators/Initializable';
  8. import { DebugProtectionFunctionIntervalTemplate } from '../../templates/debug-protection-nodes/debug-protection-function-interval-node/DebugProtectionFunctionIntervalTemplate';
  9. import { AbstractCustomNode } from '../AbstractCustomNode';
  10. import { NodeUtils } from '../../node/NodeUtils';
  11. @injectable()
  12. export class DebugProtectionFunctionIntervalNode extends AbstractCustomNode {
  13. /**
  14. * @type {string}
  15. */
  16. @initializable()
  17. private debugProtectionFunctionName: string;
  18. /**
  19. * @param {IRandomGenerator} randomGenerator
  20. * @param {IOptions} options
  21. */
  22. constructor (
  23. @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
  24. @inject(ServiceIdentifiers.IOptions) options: IOptions
  25. ) {
  26. super(randomGenerator, options);
  27. }
  28. /**
  29. * @param {string} debugProtectionFunctionName
  30. */
  31. public initialize (debugProtectionFunctionName: string): void {
  32. this.debugProtectionFunctionName = debugProtectionFunctionName;
  33. }
  34. /**
  35. * @returns {TStatement[]}
  36. */
  37. protected getNodeStructure (): TStatement[] {
  38. return NodeUtils.convertCodeToStructure(this.getTemplate());
  39. }
  40. /**
  41. * @returns {string}
  42. */
  43. protected getTemplate (): string {
  44. return format(DebugProtectionFunctionIntervalTemplate(), {
  45. debugProtectionFunctionName: this.debugProtectionFunctionName
  46. });
  47. }
  48. }