MCPcopy Create free account
hub / github.com/esengine/esengine / tryResolve

Method tryResolve

packages/core/src/Core/ServiceContainer.ts:335–341  ·  view source on GitHub ↗

* 尝试解析服务 * * 如果服务未注册,返回null而不是抛出异常。 * * @param identifier - 服务标识符(构造函数或 Symbol) * @returns 服务实例或null * * @example * ```typescript * const timer = container.tryResolve(TimerManager); * if (timer) { * timer.schedule(...); * } * ```

(identifier: ServiceIdentifier<T>)

Source from the content-addressed store, hash-verified

333 * ```
334 */
335 public tryResolve<T extends IService>(identifier: ServiceIdentifier<T>): T | null {
336 try {
337 return this.resolve(identifier);
338 } catch {
339 return null;
340 }
341 }
342
343 /**
344 * 检查服务是否已注册

Callers 15

useParticlePreviewFunction · 0.45
ParticleEditorPanelFunction · 0.45
TilemapViewportFunction · 0.45
handleMouseEnterFunction · 0.45
loadAssetsFunction · 0.45
AssetPickerDialogFunction · 0.45
convertFileSrcFunction · 0.45
TilemapEditorPanelFunction · 0.45
loadTilemapFileFunction · 0.45
parseMethod · 0.45
disposeMethod · 0.45

Calls 1

resolveMethod · 0.95

Tested by

no test coverage detected