Skip to content

Commit e013df4

Browse files
committed
Removed unnecessary INode interface
1 parent 71608cc commit e013df4

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

Microsoft.Toolkit.Uwp.UI.Animations/Xaml/AnimationSet.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ public sealed class AnimationSet : DependencyObjectCollection
3636
/// </summary>
3737
public event EventHandler? Completed;
3838

39-
/// <summary>
40-
/// An interface representing a node in an <see cref="AnimationSet"/> instance.
41-
/// </summary>
42-
public interface INode
43-
{
44-
}
45-
4639
/// <summary>
4740
/// Gets or sets a value indicating whether top level animation nodes in this collection are invoked
4841
/// 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)
124117

125118
if (IsSequential)
126119
{
127-
foreach (INode node in this)
120+
foreach (object node in this)
128121
{
129122
if (node is ITimeline timeline)
130123
{
@@ -151,6 +144,10 @@ public async Task StartAsync(UIElement element, CancellationToken token)
151144
break;
152145
}
153146
}
147+
else
148+
{
149+
ThrowArgumentException();
150+
}
154151

155152
// This should in theory only be necessary in the timeline branch, but doing this check
156153
// 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)
165162
{
166163
var builder = AnimationBuilder.Create();
167164

168-
foreach (INode node in this)
165+
foreach (object node in this)
169166
{
170167
switch (node)
171168
{
@@ -175,13 +172,18 @@ public async Task StartAsync(UIElement element, CancellationToken token)
175172
case IActivity activity:
176173
_ = activity.InvokeAsync(element, token);
177174
break;
175+
default:
176+
ThrowArgumentException();
177+
break;
178178
}
179179
}
180180

181181
await builder.StartAsync(element, token);
182182
}
183183

184184
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");
185187
}
186188

187189
/// <summary>

Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Interfaces/IActivity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
1111
/// <summary>
1212
/// An interface representing a XAML model for a custom activity or action within an <see cref="AnimationSet"/>.
1313
/// </summary>
14-
public interface IActivity : AnimationSet.INode
14+
public interface IActivity
1515
{
1616
/// <summary>
1717
/// Invokes the current activity.

Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Interfaces/ITimeline.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
1010
/// <summary>
1111
/// An interface representing a XAML model for a custom animation.
1212
/// </summary>
13-
public interface ITimeline : AnimationSet.INode
13+
public interface ITimeline
1414
{
1515
/// <summary>
1616
/// Appens the current animation to a target <see cref="AnimationBuilder"/> instance.

0 commit comments

Comments
 (0)