@@ -36,13 +36,6 @@ public sealed class AnimationSet : DependencyObjectCollection
36
36
/// </summary>
37
37
public event EventHandler ? Completed ;
38
38
39
- /// <summary>
40
- /// An interface representing a node in an <see cref="AnimationSet"/> instance.
41
- /// </summary>
42
- public interface INode
43
- {
44
- }
45
-
46
39
/// <summary>
47
40
/// Gets or sets a value indicating whether top level animation nodes in this collection are invoked
48
41
/// sequentially. This applies to both <see cref="AnimationScope"/> nodes (which will still trigger
@@ -124,7 +117,7 @@ public async Task StartAsync(UIElement element, CancellationToken token)
124
117
125
118
if ( IsSequential )
126
119
{
127
- foreach ( INode node in this )
120
+ foreach ( object node in this )
128
121
{
129
122
if ( node is ITimeline timeline )
130
123
{
@@ -151,6 +144,10 @@ public async Task StartAsync(UIElement element, CancellationToken token)
151
144
break ;
152
145
}
153
146
}
147
+ else
148
+ {
149
+ ThrowArgumentException ( ) ;
150
+ }
154
151
155
152
// This should in theory only be necessary in the timeline branch, but doing this check
156
153
// after running activities too help guard against 3rd party activities that might not
@@ -165,7 +162,7 @@ public async Task StartAsync(UIElement element, CancellationToken token)
165
162
{
166
163
var builder = AnimationBuilder . Create ( ) ;
167
164
168
- foreach ( INode node in this )
165
+ foreach ( object node in this )
169
166
{
170
167
switch ( node )
171
168
{
@@ -175,13 +172,18 @@ public async Task StartAsync(UIElement element, CancellationToken token)
175
172
case IActivity activity :
176
173
_ = activity . InvokeAsync ( element , token ) ;
177
174
break ;
175
+ default :
176
+ ThrowArgumentException ( ) ;
177
+ break ;
178
178
}
179
179
}
180
180
181
181
await builder . StartAsync ( element , token ) ;
182
182
}
183
183
184
184
Completed ? . Invoke ( this , EventArgs . Empty ) ;
185
+
186
+ static void ThrowArgumentException ( ) => throw new ArgumentException ( $ "An animation set can only contain nodes implementing either ITimeline or IActivity") ;
185
187
}
186
188
187
189
/// <summary>
0 commit comments