ing
This commit is contained in:
parent
81fe770489
commit
606d7b0e82
|
@ -2,23 +2,30 @@ import {
|
|||
ClassType,
|
||||
} from '@overflow/commons/core/type';
|
||||
|
||||
import { Assert } from '@overflow/commons/core/util';
|
||||
|
||||
import {
|
||||
InstanceDefinitionRegistry, InstanceNameGenerator,
|
||||
InstanceDefinition,
|
||||
} from '@overflow/commons/di/factory';
|
||||
|
||||
|
||||
export class InstanceDefinitionReader {
|
||||
private instanceDefinitionRegistry: InstanceDefinitionRegistry;
|
||||
private instanceNameGenerator: InstanceNameGenerator;
|
||||
|
||||
public constructor(registry: InstanceDefinitionRegistry) {
|
||||
//
|
||||
Assert.notNull(registry, 'InstanceDefinitionRegistry must not be null');
|
||||
this.instanceDefinitionRegistry = registry;
|
||||
}
|
||||
|
||||
public register(...injectables: ClassType[]): void {
|
||||
//
|
||||
injectables.forEach(injectable => {
|
||||
this.registerInstance(injectable);
|
||||
});
|
||||
}
|
||||
|
||||
public registerInstance(injectable: ClassType): void {
|
||||
//
|
||||
let instanceDefinition: InstanceDefinition = new InstanceDefinition(injectable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import {
|
||||
Annotation,
|
||||
} from '@overflow/commons/core/reflect';
|
||||
|
||||
import {
|
||||
ClassType,
|
||||
} from '@overflow/commons/core/type';
|
||||
|
||||
import { ScopeAnnotation } from '@overflow/commons/di/decorators';
|
||||
import { InstanceDefinition } from '@overflow/commons/di/factory';
|
||||
import { ScopeType } from '@overflow/commons/di/type';
|
||||
|
||||
|
||||
export class ScopeMetadataResolver {
|
||||
protected static scopeAnnotationType: ClassType<Annotation> = ScopeAnnotation;
|
||||
|
||||
public resolveScopeMetadata(definition: InstanceDefinition): ScopeType {
|
||||
let scope: ScopeType = ScopeType.Default;
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
export * from './inject';
|
||||
export * from './injectable';
|
||||
export * from './named';
|
||||
export * from './post_construct';
|
||||
export * from './pre_destroy';
|
||||
export * from './qualifier';
|
||||
export * from './resource';
|
||||
export * from './scope';
|
||||
export * from './value';
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
import {
|
||||
Annotation,
|
||||
Decorator,
|
||||
} from '@overflow/commons/core/reflect';
|
||||
|
||||
import {
|
||||
PropertyKeyType,
|
||||
TypeUtil,
|
||||
} from '@overflow/commons/core/type';
|
||||
|
||||
import {
|
||||
InstanceNameType,
|
||||
ScopeType,
|
||||
} from '@overflow/commons/di/type';
|
||||
|
||||
export interface ScopeAnnotationAttributes {
|
||||
value?: ScopeType;
|
||||
}
|
||||
|
||||
export class ScopeAnnotation extends Annotation {
|
||||
public readonly attributes: ScopeAnnotationAttributes = {
|
||||
value: ScopeType.Default,
|
||||
};
|
||||
|
||||
public constructor(value: ScopeType | ScopeAnnotationAttributes) {
|
||||
super();
|
||||
|
||||
if (undefined !== (<ScopeAnnotationAttributes>value).value) {
|
||||
this.copyAttributes(this.attributes, <ScopeAnnotationAttributes>value);
|
||||
} else {
|
||||
this.attributes.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public classDecorator<TFunction extends Function>(target: TFunction): TFunction | void {
|
||||
console.log('Scope');
|
||||
}
|
||||
|
||||
public methodDecorator<T>(target: Object, propertyKey: PropertyKeyType,
|
||||
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void {
|
||||
console.log('Scope');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const Scope = Decorator.create(ScopeAnnotation);
|
|
@ -36,6 +36,11 @@ export class InstanceDefinition {
|
|||
return this.attributes.keys();
|
||||
}
|
||||
|
||||
// Metadata
|
||||
public getMetadata(): AnnotationMetadata {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public setScope(scope: ScopeType): void {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
|
|
@ -5,4 +5,9 @@ export class InstanceNameGenerator {
|
|||
public generateInstanceName(definition: InstanceDefinition, registry: InstanceDefinitionRegistry): string {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
protected determineInstanceNameFromAnnotation(definition: InstanceDefinition): string {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
3
src/ts/@overflow/commons/di/type/annotation_metadata.ts
Normal file
3
src/ts/@overflow/commons/di/type/annotation_metadata.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export class AnnotationMetadata {
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user