-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
ComposablePartCatalogChangeEventArgs.cs
100 lines (91 loc) · 4.47 KB
/
ComposablePartCatalogChangeEventArgs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.ComponentModel.Composition.Primitives;
using System.Diagnostics;
using Microsoft.Internal;
using Microsoft.Internal.Collections;
namespace System.ComponentModel.Composition.Hosting
{
/// <summary>
/// Provides data for the <see cref="INotifyComposablePartCatalogChanged.Changed"/> and
/// <see cref="INotifyComposablePartCatalogChanged.Changing"/> events.
/// </summary>
public class ComposablePartCatalogChangeEventArgs : EventArgs
{
private readonly IEnumerable<ComposablePartDefinition> _addedDefinitions;
private readonly IEnumerable<ComposablePartDefinition> _removedDefinitions;
/// <summary>
/// Initializes a new instance of the <see cref="ComposablePartCatalogChangeEventArgs"/>.
/// </summary>
/// <param name="addedDefinitions">
/// An <see cref="IEnumerable{T}"/> of <see cref="ComposablePartDefinition"/> objects that
/// are being added to the <see cref="ComposablePartCatalog"/>.
/// </param>
/// <param name="removedDefinitions">
/// An <see cref="IEnumerable{T}"/> of <see cref="ComposablePartDefinition"/> objects that
/// are being removed from the <see cref="ComposablePartCatalog"/>.
/// </param>
/// <param name="atomicComposition">
/// A <see cref="AtomicComposition"/> representing all tentative changes that will
/// be completed if the change is successful, or discarded if it is not.
/// <see langword="null"/> if being applied outside a <see cref="AtomicComposition"/>
/// or during a <see cref="INotifyComposablePartCatalogChanged.Changed"/> event.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="addedDefinitions"/> or <paramref name="removedDefinitions"/> is <see langword="null"/>.
/// </exception>
public ComposablePartCatalogChangeEventArgs(IEnumerable<ComposablePartDefinition> addedDefinitions,
IEnumerable<ComposablePartDefinition> removedDefinitions, AtomicComposition? atomicComposition)
{
Requires.NotNull(addedDefinitions, nameof(addedDefinitions));
Requires.NotNull(removedDefinitions, nameof(removedDefinitions));
_addedDefinitions = addedDefinitions.AsArray();
_removedDefinitions = removedDefinitions.AsArray();
AtomicComposition = atomicComposition;
}
/// <summary>
/// Gets the identifiers of the parts that have been added.
/// </summary>
/// <value>
/// An <see cref="IEnumerable{T}"/> of <see cref="ComposablePartDefinition"/> objects that
/// have been added to the <see cref="ComposablePartCatalog"/>.
/// </value>
public IEnumerable<ComposablePartDefinition> AddedDefinitions
{
get
{
Debug.Assert(_addedDefinitions != null);
return _addedDefinitions;
}
}
/// <summary>
/// Gets the identifiers of the parts that have been removed.
/// </summary>
/// <value>
/// An <see cref="IEnumerable{T}"/> of <see cref="ComposablePartDefinition"/> objects that
/// have been removed from the <see cref="ComposablePartCatalog"/>.
/// </value>
public IEnumerable<ComposablePartDefinition> RemovedDefinitions
{
get
{
Debug.Assert(_removedDefinitions != null);
return _removedDefinitions;
}
}
/// <summary>
/// Gets the atomicComposition, if any, that this change applies to.
/// </summary>
/// <value>
/// A <see cref="AtomicComposition"/> that this set of changes applies too.
/// It can be <see langword="null"/> if the changes are being applied outside a
/// <see cref="AtomicComposition"/> or during a
/// <see cref="INotifyComposablePartCatalogChanged.Changed"/> event.
///
/// When the value is non-null it should be used to record temporary changed state
/// and actions that will be executed when the atomicComposition is completeed.
/// </value>
public AtomicComposition? AtomicComposition { get; }
}
}