update MEF to preview 9
[mcs.git] / class / System.ComponentModel.Composition / src / ComponentModel / System / ComponentModel / Composition / Hosting / ComposablePartCatalogChangeEventArgs.cs
blobbbb20feaf4ef8b62364b3368f498e9867918ce05
1 // -----------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 // -----------------------------------------------------------------------
4 using System;
5 using System.Collections.Generic;
6 using System.ComponentModel.Composition.Primitives;
7 using Microsoft.Internal;
8 using Microsoft.Internal.Collections;
10 namespace System.ComponentModel.Composition.Hosting
12 /// <summary>
13 /// Provides data for the <see cref="INotifyComposablePartCatalogChanged.Changed"/> and
14 /// <see cref="INotifyComposablePartCatalogChanged.Changing"/> events.
15 /// </summary>
16 public class ComposablePartCatalogChangeEventArgs : EventArgs
18 /// <summary>
19 /// Initializes a new instance of the <see cref="ComposablePartCatalogChangeEventArgs"/>.
20 /// </summary>
21 /// <param name="addedDefinitions">
22 /// An <see cref="IEnumerable{T}"/> of <see cref="ComposablePartDefinition"/> objects that
23 /// are being added to the <see cref="ComposablePartCatalog"/>.
24 /// </param>
25 /// <param name="removedDefinitions">
26 /// An <see cref="IEnumerable{T}"/> of <see cref="ComposablePartDefinition"/> objects that
27 /// are being removed from the <see cref="ComposablePartCatalog"/>.
28 /// </param>
29 /// <param name="atomicComposition">
30 /// A <see cref="AtomicComposition"/> representing all tentative changes that will
31 /// be completed if the change is successful, or discarded if it is not.
32 /// <see langword="null"/> if being applied outside a <see cref="AtomicComposition"/>
33 /// or during a <see cref="INotifyComposablePartCatalogChanged.Changed"/> event.
34 /// </param>
35 /// <exception cref="ArgumentNullException">
36 /// <paramref name="addedDefinitions"/> or <paramref name="removedDefinitions"/> is <see langword="null"/>.
37 /// </exception>
38 public ComposablePartCatalogChangeEventArgs(IEnumerable<ComposablePartDefinition> addedDefinitions,
39 IEnumerable<ComposablePartDefinition> removedDefinitions, AtomicComposition atomicComposition)
41 Requires.NotNull(addedDefinitions, "addedDefinitions");
42 Requires.NotNull(removedDefinitions, "removedDefinitions");
44 this.AddedDefinitions = addedDefinitions.AsArray();
45 this.RemovedDefinitions = removedDefinitions.AsArray();
46 this.AtomicComposition = atomicComposition;
49 /// <summary>
50 /// Gets the identifiers of the parts that have been added.
51 /// </summary>
52 /// <value>
53 /// An <see cref="IEnumerable{T}"/> of <see cref="ComposablePartDefinition"/> objects that
54 /// have been added to the <see cref="ComposablePartCatalog"/>.
55 /// </value>
56 public IEnumerable<ComposablePartDefinition> AddedDefinitions { get; private set; }
58 /// <summary>
59 /// Gets the identifiers of the parts that have been removed.
60 /// </summary>
61 /// <value>
62 /// An <see cref="IEnumerable{T}"/> of <see cref="ComposablePartDefinition"/> objects that
63 /// have been removed from from the <see cref="ComposablePartCatalog"/>.
64 /// </value>
65 public IEnumerable<ComposablePartDefinition> RemovedDefinitions { get; private set; }
67 /// <summary>
68 /// Gets the atomicComposition, if any, that this change applies to.
69 /// </summary>
70 /// <value>
71 /// A <see cref="AtomicComposition"/> that this set of changes applies too.
72 /// It can be <see langword="null"/> if the changes are being applied outside a
73 /// <see cref="AtomicComposition"/> or during a
74 /// <see cref="INotifyComposablePartCatalogChanged.Changed"/> event.
75 ///
76 /// When the value is non-null it should be used to record temporary changed state
77 /// and actions that will be executed when the atomicComposition is completeed.
78 /// </value>
79 public AtomicComposition AtomicComposition { get; private set; }