-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strategy dependency implementation (#124)
- Loading branch information
Showing
97 changed files
with
1,338 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { Dependency } from "./Dependency"; | ||
import { DependencyConfig } from "./DependencyConfig"; | ||
import { DIContainer } from "./DIContainer"; | ||
|
||
export class StrategyInstance<T> { | ||
constructor( | ||
public readonly instance: T, | ||
public readonly instanceName: string | ||
) {} | ||
} | ||
|
||
export abstract class StrategyDependency extends Dependency { | ||
protected abstract _registerInstance( | ||
container: DIContainer, | ||
childContainer: DIContainer, | ||
config: DependencyConfig | ||
): void; | ||
|
||
public abstract registerStrategy( | ||
container: DIContainer, | ||
config: DependencyConfig | ||
): void; | ||
|
||
public registerInstance( | ||
container: DIContainer, | ||
config: DependencyConfig | ||
): void { | ||
const childContainer = container.createChild(); | ||
|
||
this.register(childContainer, config); | ||
this._registerInstance(container, childContainer, config); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { TestConfig } from "./Test"; | ||
|
||
export abstract class StrategyTestBase { | ||
abstract method(instance: string): string; | ||
} | ||
|
||
export class ConcreteStrategyTest extends StrategyTestBase { | ||
constructor(private _config: TestConfig) { | ||
super(); | ||
} | ||
|
||
public get dependencyName(): string { | ||
return this._config.dependencyName; | ||
} | ||
|
||
public method(_instance: string): string { | ||
return this._config.testProperty; | ||
} | ||
} | ||
|
||
export class StrategyTest extends StrategyTestBase { | ||
constructor(private _instances: Map<string, StrategyTestBase>) { | ||
super(); | ||
} | ||
|
||
public method(instance: string): string { | ||
return this._instances.get(instance)!.method(instance); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.