Skip to content

Commit

Permalink
feat: add AbstractServiceCollection to make it replacable
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzabuzaid committed May 30, 2021
1 parent f77685e commit ead6608
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/AbstractServiceCollection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { InjectionToken } from "./InjectionToken";
import { ClassType, ImplementationFactory, Type, TypeOf } from "./Types";
import { ServiceLifetime } from "./ServiceLifetime";
import { ServiceDescriptor } from "./ServiceDescriptor";
import { Context } from "./Context";

export abstract class AbstractServiceCollection {

abstract HasService(serviceType: Type<any>): boolean;
abstract Remove(serviceType: Type<any>): void;
abstract AddService<T extends Type<any>>(serviceType: T, implementationFactory: ImplementationFactory<TypeOf<T>>, lifetime: ServiceLifetime): void;
abstract AddService<T extends Type<any>>(serviceType: T, implementation: ClassType<TypeOf<T>>, lifetime: ServiceLifetime): void;
abstract TryAddService<T>(serviceType: Type<T>, implementation: ClassType<T> | ImplementationFactory<T>, lifetime: ServiceLifetime): void;
abstract AppendService<T>(serviceType: Type<T>, implementation: ClassType<T> | ImplementationFactory<T>, lifetime: ServiceLifetime): void;
abstract ReplaceService<T>(serviceType: Type<T>, implementation: ClassType<T> | ImplementationFactory<T>, lifetime: ServiceLifetime): void;

abstract AddContext(context: Context): void;
abstract DeleteContext(context: Context): void;
abstract HasContext(context: Context): boolean;

abstract getServiceDescriptors<T>(serviceType: Type<T>): ServiceDescriptor[];

}

export type LocateOptions = { serviceType: Type<any>, multiple: boolean, context?: Context };

0 comments on commit ead6608

Please sign in to comment.