~ruther/NosSmooth.Local

ref: e3484c3c19b7c13eb58121affde55a6e2fb2e310 NosSmooth.Local/src/Extensions/NosSmooth.Extensions.SharedBinding/EventArgs/ConflictEventArgs.cs -rw-r--r-- 1.9 KiB
e3484c3c — Rutherther feat(shared): add part of shared lifetime 2 years ago
                                                                                
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
//
//  ConflictEventArgs.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.Extensions.SharedBinding.Lifetime;

namespace NosSmooth.Extensions.SharedBinding.EventArgs;

/// <summary>
/// Arguments containing information about a shared instance.
/// The conflict may be resolved by setting the correct property.
/// </summary>
public class ConflictEventArgs : System.EventArgs
{
    /// <summary>
    /// Initializes a new instance of the <see cref="ConflictEventArgs"/> class.
    /// </summary>
    /// <param name="conflictingInstances">All of the conflicting instances.</param>
    /// <param name="defaultResolution">The default method to resolve the conflict.</param>
    public ConflictEventArgs(IReadOnlyList<SharedInstanceInfo> conflictingInstances, ConflictResolution defaultResolution)
    {
        ConflictingInstances = conflictingInstances;
        Resolve = defaultResolution;
    }

    /// <summary>
    /// Gets the instances that are in conflict.
    /// </summary>
    public IReadOnlyList<SharedInstanceInfo> ConflictingInstances { get; }

    /// <summary>
    /// Gets or sets the method of resolution.
    /// </summary>
    public ConflictResolution Resolve { get; set; }

    /// <summary>
    /// Possible methods of resolution.
    /// </summary>
    public enum ConflictResolution
    {
        /// <summary>
        /// Allow the new instance, keep the old ones.
        /// </summary>
        Allow,

        /// <summary>
        /// Do not allow the new instance, keep the old ones.
        /// </summary>
        Restrict,

        /// <summary>
        /// Allow the instance, try to detach the old instance.
        /// In case the old instance cannot be detached, fall back
        /// to <see cref="Restrict"/>.
        /// </summary>
        DetachOriginal
    }
}
Do not follow this link