1
- using Pixel . Automation . AppExplorer . ViewModels . Prefab ;
1
+ using Caliburn . Micro ;
2
+ using Dawn ;
3
+ using Pixel . Automation . AppExplorer . ViewModels . Prefab ;
2
4
using Pixel . Automation . Core ;
3
5
using Pixel . Automation . Core . Attributes ;
4
6
using Pixel . Automation . Core . Components . Prefabs ;
7
+ using Pixel . Automation . Core . Components . TestCase ;
5
8
using Pixel . Automation . Core . Interfaces ;
6
9
using Pixel . Automation . Editor . Core ;
7
10
using Pixel . Automation . Editor . Core . ViewModels ;
@@ -22,6 +25,7 @@ public class PrefabDropHandlerViewModel : Wizard
22
25
private readonly IProjectFileSystem projectFileSystem ;
23
26
private readonly IScriptEngine scriptEngine ;
24
27
private readonly IScriptEditorFactory scriptEditorFactory ;
28
+ private readonly IEventAggregator eventAggregator ;
25
29
26
30
private PrefabEntity prefabEntity ;
27
31
private EntityComponentViewModel dropTarget ;
@@ -30,14 +34,18 @@ public class PrefabDropHandlerViewModel : Wizard
30
34
/// constructor
31
35
/// </summary>
32
36
/// <param name="entityManager">EntityManager of the Entity which is the drop target</param>
33
- public PrefabDropHandlerViewModel ( IEntityManager entityManager , PrefabProjectViewModel prefabProjectViewModel , EntityComponentViewModel dropTarget )
37
+ public PrefabDropHandlerViewModel ( IEntityManager entityManager , PrefabProjectViewModel prefabProjectViewModel ,
38
+ EntityComponentViewModel dropTarget )
34
39
{
35
- this . DisplayName = "(1/3) Select prefab version and mapping scripts" ;
40
+ Guard . Argument ( entityManager , nameof ( entityManager ) ) . NotNull ( ) ;
41
+ Guard . Argument ( prefabProjectViewModel , nameof ( prefabProjectViewModel ) ) . NotNull ( ) ;
42
+ this . DisplayName = "(1/3) Select prefab version and mapping scripts" ;
36
43
this . scriptEditorFactory = entityManager . GetServiceOfType < IScriptEditorFactory > ( ) ; ;
37
44
this . projectFileSystem = entityManager . GetCurrentFileSystem ( ) as IProjectFileSystem ;
38
45
this . prefabFileSystem = entityManager . GetServiceOfType < IPrefabFileSystem > ( ) ;
39
46
this . scriptEngine = entityManager . GetScriptEngine ( ) ;
40
- this . dropTarget = dropTarget ;
47
+ this . eventAggregator = entityManager . GetServiceOfType < IEventAggregator > ( ) ;
48
+ this . dropTarget = Guard . Argument ( dropTarget , nameof ( dropTarget ) ) . NotNull ( ) ;
41
49
42
50
this . prefabEntity = new PrefabEntity ( )
43
51
{
@@ -71,6 +79,21 @@ public PrefabDropHandlerViewModel(IEntityManager entityManager, PrefabProjectVie
71
79
this . stagedScreens . Add ( prefabOutputMappingScript ) ;
72
80
}
73
81
82
+
83
+ public override async Task Finish ( )
84
+ {
85
+ var addToComponent = this . dropTarget . Model ;
86
+ if ( addToComponent . TryGetAnsecstorOfType < TestCaseEntity > ( out TestCaseEntity testCaseEntity ) )
87
+ {
88
+ await this . eventAggregator . PublishOnBackgroundThreadAsync ( new PrefabAddedEventArgs ( this . prefabEntity . PrefabId , testCaseEntity . Tag ) ) ;
89
+ }
90
+ else if ( addToComponent . TryGetAnsecstorOfType < TestFixtureEntity > ( out TestFixtureEntity testFixtureEntity ) )
91
+ {
92
+ await this . eventAggregator . PublishOnBackgroundThreadAsync ( new PrefabAddedEventArgs ( this . prefabEntity . PrefabId , testFixtureEntity . Tag ) ) ;
93
+ }
94
+ await base . Finish ( ) ;
95
+ }
96
+
74
97
public override async Task Cancel ( )
75
98
{
76
99
var prefabComponentViewModel = this . dropTarget . ComponentCollection . FirstOrDefault ( a => a . Model . Equals ( this . prefabEntity ) ) ;
0 commit comments