forked from unitycontainer/interception
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterceptionBehavior.cs
More file actions
82 lines (75 loc) · 3.37 KB
/
Copy pathInterceptionBehavior.cs
File metadata and controls
82 lines (75 loc) · 3.37 KB
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
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System;
using Unity.Interception.ContainerIntegration.ObjectBuilder;
using Unity.Interception.InterceptionBehaviors;
using Unity.Policy;
namespace Unity.Interception.ContainerIntegration
{
/// <summary>
/// Stores information about a single <see cref="IInterceptionBehavior"/> to be used on an intercepted object and
/// configures a container accordingly.
/// </summary>
/// <seealso cref="IInterceptionBehavior"/>
public class InterceptionBehavior : InterceptionBehaviorBase
{
/// <summary>
/// Initializes a new instance of the <see cref="InterceptionBehavior"/> with a
/// <see cref="IInterceptionBehavior"/>.
/// </summary>
/// <param name="interceptionBehavior">The interception behavior to use.</param>
public InterceptionBehavior(IInterceptionBehavior interceptionBehavior)
: base(interceptionBehavior)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="InterceptionBehavior"/> with a
/// given type/name pair.
/// </summary>
/// <param name="behaviorType">Type of behavior to </param>
/// <param name="name"></param>
public InterceptionBehavior(Type behaviorType, string name)
: base(behaviorType, name)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="InterceptionBehavior"/> with a
/// given behavior type.
/// </summary>
/// <param name="behaviorType">Type of behavior to </param>
public InterceptionBehavior(Type behaviorType)
: base(behaviorType)
{
}
/// <summary>
/// GetOrDefault the list of behaviors for the current type so that it can be added to.
/// </summary>
/// <param name="policies">Policy list.</param>
/// <param name="implementationType">Implementation type to set behaviors for.</param>
/// <param name="name">Name type is registered under.</param>
/// <returns>An instance of <see cref="InterceptionBehaviorsPolicy"/>.</returns>
protected override InterceptionBehaviorsPolicy GetBehaviorsPolicy(IPolicyList policies, Type implementationType, string name)
{
return InterceptionBehaviorsPolicy.GetOrCreate(policies, implementationType, name);
}
}
/// <summary>
/// A generic version of <see cref="InterceptionBehavior"/> that lets you
/// specify behavior types using generic syntax.
/// </summary>
/// <typeparam name="TBehavior">Type of behavior to register.</typeparam>
public class InterceptionBehavior<TBehavior> : InterceptionBehavior
where TBehavior : IInterceptionBehavior
{
/// <summary>
/// Initializes a new instance of the <see cref="InterceptionBehavior"/> with a
/// given behavior type.
/// </summary>
public InterceptionBehavior() : base(typeof(TBehavior)) { }
/// <summary>
/// Initializes a new instance of the <see cref="InterceptionBehavior"/> with a
/// given type/name pair.
/// </summary>
/// <param name="name">Name to use to resolve the behavior.</param>
public InterceptionBehavior(string name) : base(typeof(TBehavior), name) { }
}
}