Skip to content
This repository was archived by the owner on Feb 14, 2022. It is now read-only.

Commit c40fab6

Browse files
authored
Merge pull request #152 from JacopoWolf/rel/3
Rel/3
2 parents 94f8b1f + 5dd3e45 commit c40fab6

47 files changed

Lines changed: 2143 additions & 2003 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

StackInjector/Attributes/IgnoredAttribute.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
namespace StackInjector.Attributes
44
{
55

6-
/// <summary>
7-
/// Indicates this field or property should be ignored from injection
8-
/// </summary>
9-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
10-
public sealed class IgnoredAttribute : Attribute
11-
{
12-
13-
}
6+
/// <summary>
7+
/// Indicates this field or property should be ignored from injection
8+
/// </summary>
9+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
10+
public sealed class IgnoredAttribute : Attribute
11+
{
12+
13+
}
1414

1515
}

StackInjector/Attributes/ServedAttribute.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@
33

44
namespace StackInjector.Attributes
55
{
6-
/// <summary>
7-
/// Indicates this field or property should be injected.
8-
/// </summary>
9-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
10-
public sealed class ServedAttribute : Attribute
11-
{
6+
/// <summary>
7+
/// Indicates this field or property should be injected.
8+
/// </summary>
9+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
10+
public sealed class ServedAttribute : Attribute
11+
{
1212

13-
/// <summary>
14-
/// The target version.
15-
/// </summary>
16-
public double TargetVersion { get; set; }
13+
/// <summary>
14+
/// The target version.
15+
/// </summary>
16+
public double TargetVersion { get; set; }
1717

18-
/// <summary>
19-
/// <para>How the specified TargetVersion should be found.</para>
20-
/// <para>could be overriden by <see cref="StackWrapperSettings"/></para>
21-
/// </summary>
22-
public ServedVersionTargetingMethod TargetingMethod
23-
{
24-
get => this._targeting;
25-
set
26-
{
27-
this._targetingDefined = true;
28-
this._targeting = value;
29-
}
30-
}
18+
/// <summary>
19+
/// <para>How the specified TargetVersion should be found.</para>
20+
/// <para>could be overriden by <see cref="StackWrapperSettings"/></para>
21+
/// </summary>
22+
public ServedVersionTargetingMethod TargetingMethod
23+
{
24+
get => this._targeting;
25+
set
26+
{
27+
this._targetingDefined = true;
28+
this._targeting = value;
29+
}
30+
}
3131

3232

33-
private ServedVersionTargetingMethod _targeting;
34-
internal bool _targetingDefined;
33+
private ServedVersionTargetingMethod _targeting;
34+
internal bool _targetingDefined;
3535

36-
}
36+
}
3737

3838
}

StackInjector/Attributes/ServiceAttribute.cs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,43 @@
33

44
namespace StackInjector.Attributes
55
{
6-
/// <summary>
7-
/// Allows a class to be used a service for other classes.
8-
/// </summary>
9-
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
10-
public sealed class ServiceAttribute : Attribute
11-
{
12-
/// <summary>
13-
/// The version of this service.
14-
/// </summary>
15-
public double Version { get; set; } = -0.0;
6+
/// <summary>
7+
/// Allows a class to be used a service for other classes.
8+
/// </summary>
9+
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
10+
public sealed class ServiceAttribute : Attribute
11+
{
12+
/// <summary>
13+
/// The version of this service.
14+
/// </summary>
15+
public double Version { get; set; } = -0.0;
1616

17-
/// <summary>
18-
/// The instantiation pattern for this service.
19-
/// </summary>
20-
public InstantiationPattern Pattern
21-
{
22-
get => this._pattern;
23-
set => this._pattern = value;
24-
}
17+
/// <summary>
18+
/// The instantiation pattern for this service.
19+
/// </summary>
20+
public InstantiationPattern Pattern
21+
{
22+
get => this._pattern;
23+
set => this._pattern = value;
24+
}
2525

2626

27-
/// <summary>
28-
/// How properties and fields of this service should be injected.
29-
/// </summary>
30-
public ServingMethods Serving
31-
{
32-
get => this._serving;
33-
set
34-
{
35-
this._servingDefined = true;
36-
this._serving = value;
37-
}
38-
}
27+
/// <summary>
28+
/// How properties and fields of this service should be injected.
29+
/// </summary>
30+
public ServingMethods Serving
31+
{
32+
get => this._serving;
33+
set
34+
{
35+
this._servingDefined = true;
36+
this._serving = value;
37+
}
38+
}
3939

40-
private InstantiationPattern _pattern = InstantiationPattern.Singleton;
41-
private ServingMethods _serving;
42-
internal bool _servingDefined;
43-
}
40+
private InstantiationPattern _pattern = InstantiationPattern.Singleton;
41+
private ServingMethods _serving;
42+
internal bool _servingDefined;
43+
}
4444

4545
}

StackInjector/Core/AsyncStackWrapperCore.cs

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,69 +5,71 @@
55

66
namespace StackInjector.Core
77
{
8-
internal abstract partial class AsyncStackWrapperCore<T> : StackWrapperCore, IAsyncStackWrapperCore<T>
9-
{
8+
internal abstract partial class AsyncStackWrapperCore<T> : StackWrapperCore, IAsyncStackWrapperCore<T>
9+
{
1010

11-
public event Action<T> OnElaborated;
11+
public event Action<T> OnElaborated;
1212

1313

14-
// used to cancel everything
15-
protected internal readonly CancellationTokenSource cancelPendingTasksSource = new CancellationTokenSource();
14+
// used to cancel everything
15+
protected internal readonly CancellationTokenSource cancelPendingTasksSource = new CancellationTokenSource();
1616

17-
// exposes the token
18-
public CancellationToken PendingTasksCancellationToken
19-
=> this.cancelPendingTasksSource.Token;
17+
// exposes the token
18+
public CancellationToken PendingTasksCancellationToken
19+
=> this.cancelPendingTasksSource.Token;
2020

21-
// used to lock access to tasks
22-
private readonly object _listAccessLock = new object();
21+
// used to lock access to tasks
22+
private readonly object _listAccessLock = new object();
2323

24-
// used to endure Elaborated() and Elaborate() are called together
25-
private bool _exclusiveExecution;
24+
// used to endure Elaborated() and Elaborate() are called together
25+
private bool _exclusiveExecution;
2626

27-
public bool IsElaborating => this._exclusiveExecution;
27+
public bool IsElaborating => this._exclusiveExecution;
2828

29-
// asyncronously waited for new events if TaskList is empty
30-
private readonly SemaphoreSlim _emptyListAwaiter = new SemaphoreSlim(0);
29+
// asyncronously waited for new events if TaskList is empty
30+
private readonly SemaphoreSlim _emptyListAwaiter = new SemaphoreSlim(0);
3131

32-
// pending tasks
33-
protected internal LinkedList<Task<T>> tasks = new LinkedList<Task<T>>();
32+
// pending tasks
33+
protected internal LinkedList<Task<T>> tasks = new LinkedList<Task<T>>();
3434

3535

36-
// register an event that in case the list is empty, release the empty event listener.
37-
internal AsyncStackWrapperCore ( InjectionCore core, Type toRegister ) : base(core, toRegister) =>
38-
this.cancelPendingTasksSource.Token.Register(this.ReleaseListAwaiter);
36+
// register an event that in case the list is empty, release the empty event listener.
37+
internal AsyncStackWrapperCore ( InjectionCore core, Type toRegister ) : base(core, toRegister)
38+
{
39+
this.cancelPendingTasksSource.Token.Register(this.ReleaseListAwaiter);
40+
}
3941

4042

4143

42-
#region IDisposable Support
44+
#region IDisposable Support
4345

44-
private bool disposedValue;
46+
private bool disposedValue;
4547

46-
public override void Dispose ()
47-
{
48-
if( !this.disposedValue )
49-
{
48+
public override void Dispose ()
49+
{
50+
if( !this.disposedValue )
51+
{
5052

51-
// managed resources
52-
this.cancelPendingTasksSource.Cancel(); // cancel all pending tasks
53-
this.ReleaseListAwaiter(); // in case it's waiting on the empty list
53+
// managed resources
54+
this.cancelPendingTasksSource.Cancel(); // cancel all pending tasks
55+
this.ReleaseListAwaiter(); // in case it's waiting on the empty list
5456

55-
this.cancelPendingTasksSource.Dispose();
56-
this._emptyListAwaiter.Dispose();
57+
this.cancelPendingTasksSource.Dispose();
58+
this._emptyListAwaiter.Dispose();
5759

5860

59-
// big objects
60-
this.tasks.Clear();
61-
this.tasks = null;
61+
// big objects
62+
this.tasks.Clear();
63+
this.tasks = null;
6264

63-
// clean instantiated objects
64-
this.Core.RemoveInstancesDiff();
65+
// clean instantiated objects
66+
this.Core.RemoveInstancesDiff();
6567

6668

67-
this.disposedValue = true;
68-
}
69-
}
70-
#endregion
71-
}
69+
this.disposedValue = true;
70+
}
71+
}
72+
#endregion
73+
}
7274

7375
}

0 commit comments

Comments
 (0)