@jems/di
Version:
An implementation of IoC pattern based on dependency injection that allows you to granulate and decouple your libraries or applications. Wrote using SOLID principles and a variety OOP patterns implementations.
124 lines (123 loc) • 5.72 kB
TypeScript
import { DependencyMetadata } from '../dependencyMetadata';
import { InAndWhenSyntax } from './inAndWhenSyntax';
import { ServicingStrategy } from '../servicing-strategies/servicingStrategy';
import { WhenSyntax } from './whenSyntax';
import { DeliveryStrategy } from '../delivery-strategies/deliveryStrategy';
import { ResolutionContext } from '../resolutionContext';
import { WithAndAsAndInAndWhenSyntax } from './withAndAsAndInAndWhenSyntax';
import { AsAndInAndWhenSyntax } from './asAndInAndWhenSyntax';
/**
* Represents a syntax that allow setup the dependecy resolution behavior.
*/
export declare class BehaviorSyntax implements WithAndAsAndInAndWhenSyntax {
/**
* Represents the dependency metadata to affect in a fluently way.
*/
private _dependencyMetadata;
/**
* Creates a new behavior syntax that allow setup the dependecy resolution behavior.
* @param dependencyMetadata Represents the dependency metadata to affect in a fluently way.
*/
constructor(dependencyMetadata: DependencyMetadata);
/*********************************
* The Dependencies (With Syntax)
*********************************/
/**
* Setup the aliases that will repsents the argument names with the given aliases.
* @param aliases Represents the aliases that will repsents the argument names.
* @return A syntax extension to setup the serving, delivery and conditions.
*/
with(aliases: string[]): AsAndInAndWhenSyntax;
/*********************************
* The servicing (As Syntax)
*********************************/
/**
* Setup the current alias bind to be served as an instace.
* @return A syntax extension to setup the delivery and conditions.
*/
asInstance(): InAndWhenSyntax;
/**
* Setup the current alias bind to be served as the result of the referenced function..
* @return A syntax extension to setup the delivery and conditions.
*/
asBuilderFunction(): InAndWhenSyntax;
/**
* Setup the current alias bind to be served as a constant.
* @return A syntax extension to setup the delivery and conditions.
*/
asConstant(): InAndWhenSyntax;
/**
* Setup the current alias bind to be served with the given servicing strategy.
* @param servicingStrategy Represents the servicing strategy to serve the reference.
* @return A syntax extension to setup the delivery and conditions.
*/
as(servicingStrategy: ServicingStrategy): InAndWhenSyntax;
/*********************************
* The delivery modes (In Syntax)
*********************************/
/**
* Setup the current alias bind to be served in each call.
* @return A syntax extension to setup conditions.
*/
inPerCallMode(): WhenSyntax;
/**
* Setup the current alias bind to be served once per each resolution process.
* @return A syntax extension to setup conditions.
*/
inPerResolutionMode(): WhenSyntax;
/**
* Setup the current alias bind to be served only once.
* @return A syntax extension to setup conditions.
*/
inSingletonMode(): WhenSyntax;
/**
* Setup the current alias bind to be served once per container.
* @return A syntax extension to setup conditions.
*/
inContainerizedMode(): WhenSyntax;
/**
* Setup the current alias bind to be delivered with the given delivery strategy.
* @param deliveryStrategy Represents the delivery strategy to deliver the reference.
* @return A syntax extension to setup conditions.
*/
inMode(deliveryStrategy: DeliveryStrategy): WhenSyntax;
/*********************************
* The validators (When Syntax)
*********************************/
/**
* Setup the current alias bind to be valid when the target be an ancestor of the given types.
* @param types Represents the types that must be the ancestor of the bind.
* @return A syntax extention to setup conditions.
*/
whenAncestorsAre(...types: Function[]): WhenSyntax;
/**
* Setup the current alias bind to be valid when the metadata is being injected into the given aliases.
* @param aliases Represents the aliases where the bind must be injected
* @return A syntax extention to setup conditions.
*/
whenInjectedIntoAliases(...aliases: string[]): WhenSyntax;
/**
* Setup the current alias bind to be valid when the metadata is being injected into the given types.
* @param types Represents the types where the bind must be injected.
* @return A syntax extention to setup conditions.
*/
whenInjectedIntoTypes(...types: Function[]): WhenSyntax;
/**
* Setup the current alias bind to be valid when the metadata is being injected exactly into the given aliases.
* @param aliases Represents the aliases where the bind must be exactly injected
* @return A syntax extention to setup conditions.
*/
whenInjectedExactlyIntoAliases(...aliases: string[]): WhenSyntax;
/**
* Setup the current alias bind to be valid when the metadata is being injected exactly into the given types.
* @param types Represents the types where the bind must be exactly injected.
* @return A syntax extention to setup conditions.
*/
whenInjectedExactlyIntoTypes(...types: Function[]): WhenSyntax;
/**
* Setup the current alias bind to be valid when the given validator is successfully.
* @param validator Represents a custom validator.
* @return A syntax extention to setup conditions.
*/
when(validator: (resolutionContext: ResolutionContext, dependencyMetadata: DependencyMetadata) => boolean): WhenSyntax;
}