-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Release 5.0.0
Showing
158 changed files
with
5,150 additions
and
1,444 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
13 changes: 13 additions & 0 deletions
13
examples/Csharp.ExampleApplication/Hooks/InitializeMigration/CustomContext.cs
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,13 @@ | ||
using System; | ||
|
||
namespace Csharp.ExampleApplication.Hooks.InitializeMigration | ||
{ | ||
#region class | ||
|
||
public class CustomContext | ||
{ | ||
public Guid CustomerId { get; set; } | ||
} | ||
|
||
#endregion | ||
} |
23 changes: 23 additions & 0 deletions
23
examples/Csharp.ExampleApplication/Hooks/InitializeMigration/SetMigrationContextHook.cs
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,23 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Tableau.Migration.Engine.Hooks; | ||
|
||
namespace Csharp.ExampleApplication.Hooks.InitializeMigration | ||
{ | ||
#region class | ||
|
||
internal class SetMigrationContextHook : IInitializeMigrationHook | ||
{ | ||
public Task<IInitializeMigrationHookResult?> ExecuteAsync(IInitializeMigrationHookResult ctx, CancellationToken cancel) | ||
{ | ||
var customContext = ctx.ScopedServices.GetRequiredService<CustomContext>(); | ||
customContext.CustomerId = Guid.NewGuid(); | ||
|
||
return Task.FromResult<IInitializeMigrationHookResult?>(ctx); | ||
} | ||
} | ||
|
||
#endregion | ||
} |
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
10 changes: 10 additions & 0 deletions
10
examples/Python.ExampleApplication/Hooks/initialize_migration/set_custom_context_hook.py
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,10 @@ | ||
from tableau_migration import( | ||
InitializeMigrationHookBase, | ||
IInitailizeMigrationHookResult | ||
) | ||
|
||
from Csharp.ExampleApplication.Hooks.InitializeMigration import CustomContext | ||
|
||
class SetMigrationContextHook(InitializeMigrationHookBase): | ||
def execute(self, ctx: IInitailizeMigrationHookResult) -> IInitailizeMigrationHookResult: | ||
ctx.scoped_services._get_service(CustomContext) |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.302", | ||
"version": "8.0.403", | ||
"rollForward": "latestMajor" | ||
} | ||
} |
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,7 @@ | ||
# Initialize Migration | ||
|
||
Initialize Migration Hooks allow custom logic to run after a migration startup has been validated but before any migration work is performed. | ||
|
||
The following samples cover some common scenarios: | ||
|
||
- [Sample: Set Custom Migration Scoped Context](~/samples/initialize-migration/set_custom_context.md) |
57 changes: 57 additions & 0 deletions
57
src/Documentation/samples/initialize-migration/set_custom_context.md
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,57 @@ | ||
# Sample: Set Custom Migration Scoped Context | ||
|
||
This example demonstrates how to set custom context in the migration scoped dependency injection container using an initialize migration hook. | ||
This is useful when other hooks like filters are registered with dependency injection and rely on migration scoped services. | ||
|
||
# [Python](#tab/Python) | ||
|
||
#### Custom Context Service Class | ||
|
||
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Hooks/InitializeMigration/CustomContext.cs#class)] | ||
|
||
#### Custom Context Service Class Dependency Injection | ||
|
||
[Learn more.](~/articles/dependency_injection.md) | ||
|
||
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Program.cs#SetCustomContext-Service-DI)] | ||
|
||
#### Initialize Migration Hook Class | ||
|
||
[!code-python[](../../../../examples/Python.ExampleApplication/hooks/initialize_migration/set_custom_context_hook.py)] | ||
|
||
#### Registration | ||
|
||
[Learn more.](~/samples/index.md?tabs=Python#hook-registration) | ||
|
||
[//]: <> (Adding this as code as regions are not supported in Python snippets) | ||
```Python | ||
plan_builder.hooks.add(SetMigrationContextHook) | ||
``` | ||
|
||
# [C#](#tab/CSharp) | ||
|
||
#### Custom Context Service Class | ||
|
||
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Hooks/InitializeMigration/CustomContext.cs#class)] | ||
|
||
#### Custom Context Service Class Dependency Injection | ||
|
||
[Learn more.](~/articles/dependency_injection.md) | ||
|
||
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Program.cs#SetCustomContext-Service-DI)] | ||
|
||
#### Initialize Migration Hook Class | ||
|
||
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Hooks/InitializeMigration/SetMigrationContextHook.cs#class)] | ||
|
||
#### Registration | ||
|
||
[Learn more.](~/samples/index.md?tabs=CSharp#hook-registration) | ||
|
||
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/MyMigrationApplication.cs#SetCustomContext-Registration)] | ||
|
||
#### Dependency Injection | ||
|
||
[Learn more.](~/articles/dependency_injection.md) | ||
|
||
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Program.cs#SetCustomContext-Hook-DI)] |
Oops, something went wrong.