Advertisement
djbob2000

Untitled

Aug 7th, 2024
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { MetaConfigService } from "@server/meta/fd-meta-core/meta-config/meta-config-service";
  2. import { singleOrDefault } from "@server/fd/fd-toolbox/collections/single-warnings";
  3. import { FdLifetimeScope } from "@server/fd/fd-toolbox/di/fd-lifetime-scope";
  4.  
  5. let metaConfigServices: MetaConfigService[] | null = null;
  6.  
  7. export function getMetaConfigService(resourceName: string): MetaConfigService | undefined {
  8.     const services = getMetaConfigServices();
  9.     return singleOrDefault(services.filter(h => h.ResourceName === resourceName));
  10. }
  11.  
  12. function getMetaConfigServices(): MetaConfigService[] {
  13.     if (!metaConfigServices) {
  14.         const lifetimeScope = new FdLifetimeScope();
  15.         metaConfigServices = lifetimeScope.resolve<MetaConfigService[]>("MetaConfigServices");
  16.         if (!Array.isArray(metaConfigServices)) {
  17.             throw new Error("Failed to resolve MetaConfigServices");
  18.         }
  19.     }
  20.     return metaConfigServices;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement