##// END OF EJS Templates
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
cin -
r187:dd4a3590f9c6 ref20160224
parent child
Show More
@@ -0,0 +1,45
1 using System;
2 using System.Threading;
3
4 namespace Implab {
5 /// <summary>
6 /// Π‘Π°Π·ΠΎΠ²Ρ‹ΠΉ класс для Ρ€Π΅Π°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ Π·Π°Π΄Π°Ρ‡ΡŒ. Π—Π°Π΄Π°Ρ‡Π° прСдставляСт собой Π½Π΅ΠΊΡ‚ΠΎΡ€ΠΎΠ΅
7 /// дСйствиС, ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠ΅ ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠ½ΠΈΡ†ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ ΠΈ ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ Π΅Π³ΠΎ выполнСния
8 /// Π² Π²ΠΈΠ΄Π΅ обСщания, для этого ΠΎΠ½ΠΎ Ρ€Π΅Π°Π»ΠΈΠ·ΡƒΠ΅Ρ‚ интСрфСйс <see cref="IPromise"/>.
9 /// </summary>
10 /// <remarks>
11 /// Π”Π°Π½Π½Ρ‹ΠΉ класс опрСдСляСт стандартноС ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ ΠΏΡ€ΠΈ ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚ΠΊΠΈ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ΠΎΠ², Π² частности
12 /// ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚ΠΊΡƒ <see cref="System.OperationCanceledException"/> ΠΈ <see cref="PromiseTransientException"/>
13 /// </remarks>
14 public abstract class AbstractTask : AbstractPromise {
15 int m_cancelationLock;
16
17 /// <summary>
18 /// ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅Ρ‚ эксклюзивноС ΠΏΡ€Π°Π²ΠΎ ΠΎΡ‚ΠΌΠ΅Π½Ρ‹ задания, ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ΡΡ для ΠΎΡ‚ΠΌΠ΅Π½Ρ‹ задания Π΄ΠΎ Π½Π°Ρ‡Π°Π»Π° Π΅Π³ΠΎ выполнСния.
19 /// </summary>
20 /// <returns><c>true</c>, if cancelation was locked, <c>false</c> otherwise.</returns>
21 protected bool LockCancelation() {
22 return 0 == Interlocked.CompareExchange(ref m_cancelationLock, 1, 0);
23 }
24
25
26
27 protected void SetErrorInternal(Exception error) {
28 // unwrap
29 while (error is PromiseTransientException && error.InnerException != null)
30 error = error.InnerException;
31
32 if (error is OperationCanceledException)
33 SetCancelled(error);
34 else
35 SetError(error);
36 }
37
38 protected void SetCancelledInternal(Exception reason) {
39 SetCancelled(
40 reason == null ? new OperationCanceledException() : reason is OperationCanceledException ? reason : new OperationCanceledException(null, reason)
41 );
42 }
43 }
44 }
45
@@ -0,0 +1,36
1 using System;
2 using System.Threading;
3
4 namespace Implab {
5 public abstract class AbstractTask<T> : AbstractPromise<T> {
6 int m_cancelationLock;
7
8 /// <summary>
9 /// ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅Ρ‚ эксклюзивноС ΠΏΡ€Π°Π²ΠΎ ΠΎΡ‚ΠΌΠ΅Π½Ρ‹ задания, ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ΡΡ для ΠΎΡ‚ΠΌΠ΅Π½Ρ‹ задания Π΄ΠΎ Π½Π°Ρ‡Π°Π»Π° Π΅Π³ΠΎ выполнСния.
10 /// </summary>
11 /// <returns><c>true</c>, if cancelation was locked, <c>false</c> otherwise.</returns>
12 protected bool LockCancelation() {
13 return 0 == Interlocked.CompareExchange(ref m_cancelationLock, 1, 0);
14 }
15
16
17
18 protected void SetErrorInternal(Exception error) {
19 // unwrap
20 while (error is PromiseTransientException && error.InnerException != null)
21 error = error.InnerException;
22
23 if (error is OperationCanceledException)
24 SetCancelled(error);
25 else
26 SetError(error);
27 }
28
29 protected void SetCancelledInternal(Exception reason) {
30 SetCancelled(
31 reason == null ? new OperationCanceledException() : reason is OperationCanceledException ? reason : new OperationCanceledException(null, reason)
32 );
33 }
34 }
35 }
36
@@ -1,34 +1,36
1 using System;
1 using System;
2
2
3 namespace Implab {
3 namespace Implab {
4 public class ActionChainTask : ActionChainTaskBase, IDeferred {
4 public class ActionChainTask : ActionChainTaskBase, IDeferred {
5 readonly Func<IPromise> m_task;
5 readonly Func<IPromise> m_task;
6
6
7 /// <summary>
7 /// <summary>
8 /// Initializes a new instance of the <see cref="Implab.ActionChainTask"/> class.
8 /// Initializes a new instance of the <see cref="Implab.ActionChainTask"/> class.
9 /// </summary>
9 /// </summary>
10 /// <param name="task">The operation which will be performed when the <see cref="Resolve()"/> is called.</param>
10 /// <param name="task">The operation which will be performed when the <see cref="Resolve()"/> is called.</param>
11 /// <param name="error">The error handler which will invoke when the <see cref="Reject(Exception)"/> is called or when the task fails with an error.</param>
11 /// <param name="error">The error handler which will invoke when the <see cref="Reject(Exception)"/> is called or when the task fails with an error.</param>
12 /// <param name="cancel">The cancellation handler.</param>
12 /// <param name="cancel">The cancellation handler.</param>
13 /// <param name="autoCancellable">If set to <c>true</c> will automatically accept
13 /// <param name="autoCancellable">If set to <c>true</c> will automatically accept
14 /// all cancel requests before the task is started with <see cref="Resolve()"/>,
14 /// all cancel requests before the task is started with <see cref="Resolve()"/>,
15 /// after that all requests are directed to the task.</param>
15 /// after that all requests are directed to the task.</param>
16 public ActionChainTask(Func<IPromise> task, Func<Exception, IPromise> error, Func<Exception, IPromise> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) {
16 public ActionChainTask(Func<IPromise> task, Func<Exception, IPromise> error, Func<Exception, IPromise> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) {
17 m_task = task;
17 m_task = task;
18 }
18 }
19
19
20 public void Resolve() {
20 public void Resolve() {
21 if (m_task != null && LockCancelation()) {
21 if (m_task != null && LockCancelation()) {
22 try {
22 try {
23 var p = m_task();
23 var p = m_task();
24 p.On(SetResult, HandleErrorInternal, SetCancelled);
24 p.On(SetResult, HandleErrorInternal, HandleCancelInternal);
25 CancellationRequested(p.Cancel);
25 CancellationRequested(p.Cancel);
26 } catch (OperationCanceledException reason){
27 HandleCancelInternal(reason);
26 } catch(Exception err) {
28 } catch(Exception err) {
27 HandleErrorInternal(err);
29 HandleErrorInternal(err);
28 }
30 }
29 }
31 }
30 }
32 }
31
33
32 }
34 }
33 }
35 }
34
36
@@ -1,75 +1,62
1 using System;
1 using System;
2 using System.Threading;
2 using System.Threading;
3
3
4 namespace Implab {
4 namespace Implab {
5 public class ActionChainTaskBase : AbstractPromise {
5 public class ActionChainTaskBase : AbstractTask {
6 readonly Func<Exception, IPromise> m_error;
6 readonly Func<Exception, IPromise> m_error;
7 readonly Func<Exception, IPromise> m_cancel;
7 readonly Func<Exception, IPromise> m_cancel;
8
8
9 int m_cancelationLock;
10
11 protected ActionChainTaskBase(Func<Exception, IPromise> error, Func<Exception, IPromise> cancel, bool autoCancellable) {
9 protected ActionChainTaskBase(Func<Exception, IPromise> error, Func<Exception, IPromise> cancel, bool autoCancellable) {
12 m_error = error;
10 m_error = error;
13 m_cancel = cancel;
11 m_cancel = cancel;
14 if (autoCancellable)
12 if (autoCancellable)
15 CancellationRequested(CancelOperation);
13 CancellationRequested(CancelOperation);
16 }
14 }
17
15
18 public void Reject(Exception error) {
16 public void Reject(Exception error) {
19 if (LockCancelation())
17 if (LockCancelation())
20 HandleErrorInternal(error);
18 HandleErrorInternal(error);
21 }
19 }
22
20
23 public override void CancelOperation(Exception reason) {
21 public override void CancelOperation(Exception reason) {
24 if (LockCancelation()) {
22 if (LockCancelation())
25 if (!(reason is OperationCanceledException))
23 // ΠΎΡ‚ΠΌΠ΅Π½Π° Π²Ρ‹Π·Π²Π°Π½Π° Π΄ΠΎ Π½Π°Ρ‡Π°Π»Π° выполнСния Π·Π°Π΄Π°Ρ‡ΠΈ
26 reason = reason != null ? new OperationCanceledException(null, reason) : new OperationCanceledException();
24 HandleCancelInternal(reason);
25 }
27
26
27 protected void HandleCancelInternal(Exception reason) {
28 if (m_cancel != null) {
28 if (m_cancel != null) {
29 try {
29 try {
30 m_cancel(reason).On(SetResult, HandleErrorInternal, HandleCancelInternal);
30 // Π²Ρ‹Π·Ρ‹Π²Π°Π΅ΠΌ ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚Ρ‡ΠΈΠΊ ΠΎΡ‚ΠΌΠ΅Π½Ρ‹
31 var p = m_cancel(reason);
32 p.On(SetResult, HandleErrorInternal, SetCancelledInternal);
33 // сообщаСм асинхронной ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ, Ρ‡Ρ‚ΠΎ ΠΊΠ»ΠΈΠ΅Π½Ρ‚ ΡƒΠΆΠ΅ Π½Π΅ Ρ…ΠΎΡ‡Π΅Ρ‚ ΠΏΠΎΠ»ΡƒΡ‡Π°Ρ‚ΡŒ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚
34 // Ρ‚.Π΅. Ссли ΠΎΠ½ ΠΈΠ½ΠΈΡ†ΠΈΠΈΡ€ΠΎΠ²Π°Π» ΠΎΡ‚ΠΌΠ΅Π½Ρƒ, Π·Π°Π΄Π°Ρ‡Π° ΠΎΡ‚ΠΌΠ΅Π½ΠΈΠ»Π°ΡΡŒ, вызвался ΠΎΠ±Ρ€Π°Π±ΠΎΡ‡ΠΈΠΊ ΠΎΡ‚ΠΌΠ΅Π½Ρ‹
35 // ΠΎΡ‚Π±Ρ€Π°Π±ΠΎΡ‚Ρ‡ΠΈΠΊΡƒ сообщили, Ρ‡Ρ‚ΠΎ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ ΡƒΠΆΠ΅ Π½Π΅ Π½ΡƒΠΆΠ΅Π½ ΠΈ ΡƒΠΆΠ΅ сам ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚Ρ‡ΠΈΠΊ Ρ€Π΅ΡˆΠ°Π΅Ρ‚
36 // ΠΎΡ‚Π΄Π°Π²Π°Ρ‚ΡŒ Π»ΠΈ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ ΠΈΠ»ΠΈ ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€Π΄ΠΈΡ‚ΡŒ ΠΎΡ‚ΠΌΠ΅Π½Ρƒ (ΠΈΠ»ΠΈ Π²Π΅Ρ€Π½ΡƒΡ‚ΡŒ ΠΎΡˆΠΈΠ±ΠΊΡƒ).
37 CancellationRequested(p.Cancel);
31 } catch (Exception err) {
38 } catch (Exception err) {
32 HandleErrorInternal(err);
39 HandleErrorInternal(err);
33 }
40 }
34 } else {
41 } else {
35 HandleErrorInternal(reason);
42 HandleErrorInternal(reason ?? new OperationCanceledException());
36 }
37 }
43 }
38 }
44 }
39
45
40 void HandleCancelInternal(Exception reason) {
46 protected void HandleErrorInternal(Exception error) {
41 if (!(reason is OperationCanceledException))
42 reason = reason != null ? new OperationCanceledException(null, reason) : new OperationCanceledException();
43 HandleErrorInternal(reason);
44 }
45
46 void HandleErrorInternal(Exception error) {
47 if (m_error != null) {
47 if (m_error != null) {
48 try {
48 try {
49 var p = m_error(error);
49 var p = m_error(error);
50 p.On(SetResult, SetError, SetCancelled);
50 p.On(SetResult, SetErrorInternal, SetCancelledInternal);
51 CancellationRequested(p.Cancel);
51 CancellationRequested(p.Cancel);
52 } catch (Exception err) {
52 } catch (Exception err) {
53 error = err;
53 SetErrorInternal(error);
54 }
54 }
55 } else {
55 } else {
56 SetErrorInternal(error);
56 SetErrorInternal(error);
57 }
57 }
58 }
58 }
59
59
60 void SetErrorInternal(Exception error) {
61 while (error is PromiseTransientException)
62 error = error.InnerException;
63
64 if (error is OperationCanceledException)
65 SetCancelled(error);
66 else
67 SetError(error);
68 }
69
70 protected bool LockCancelation() {
71 return 0 == Interlocked.CompareExchange(ref m_cancelationLock, 1, 0);
72 }
73 }
60 }
74 }
61 }
75
62
@@ -1,25 +1,27
1 using System;
1 using System;
2
2
3 namespace Implab {
3 namespace Implab {
4 public class ActionChainTask<T> : ActionChainTaskBase, IDeferred<T> {
4 public class ActionChainTask<T> : ActionChainTaskBase, IDeferred<T> {
5 readonly Func<T, IPromise> m_task;
5 readonly Func<T, IPromise> m_task;
6
6
7 public ActionChainTask(Func<T, IPromise> task, Func<Exception, IPromise> error, Func<Exception, IPromise> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) {
7 public ActionChainTask(Func<T, IPromise> task, Func<Exception, IPromise> error, Func<Exception, IPromise> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) {
8 m_task = task;
8 m_task = task;
9 }
9 }
10
10
11 public void Resolve(T value) {
11 public void Resolve(T value) {
12 if (m_task != null && LockCancelation()) {
12 if (m_task != null && LockCancelation()) {
13 try {
13 try {
14 var p = m_task(value);
14 var p = m_task(value);
15 p.On(SetResult, HandleErrorInternal, SetCancelled);
15 p.On(SetResult, HandleErrorInternal, HandleCancelInternal);
16 CancellationRequested(p.Cancel);
16 CancellationRequested(p.Cancel);
17 } catch (OperationCanceledException reason) {
18 HandleCancelInternal(reason);
17 } catch(Exception err) {
19 } catch(Exception err) {
18 HandleErrorInternal(err);
20 HandleErrorInternal(err);
19 }
21 }
20 }
22 }
21 }
23 }
22
24
23 }
25 }
24 }
26 }
25
27
@@ -1,22 +1,24
1 using System;
1 using System;
2
2
3 namespace Implab {
3 namespace Implab {
4 public class ActionTask : ActionTaskBase, IDeferred {
4 public class ActionTask : ActionTaskBase, IDeferred {
5 readonly Action m_task;
5 readonly Action m_task;
6 public ActionTask(Action task, Action<Exception> error, Action<Exception> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) {
6 public ActionTask(Action task, Action<Exception> error, Action<Exception> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) {
7 m_task = task;
7 m_task = task;
8 }
8 }
9
9
10 public void Resolve() {
10 public void Resolve() {
11 if (m_task != null && LockCancelation()) {
11 if (m_task != null && LockCancelation()) {
12 try {
12 try {
13 m_task();
13 m_task();
14 SetResult();
14 SetResult();
15 } catch(OperationCanceledException reason) {
16 HandleCancelInternal(reason);
15 } catch(Exception err) {
17 } catch(Exception err) {
16 HandleErrorInternal(err);
18 HandleErrorInternal(err);
17 }
19 }
18 }
20 }
19 }
21 }
20 }
22 }
21 }
23 }
22
24
@@ -1,57 +1,53
1 using System;
1 using System;
2 using System.Threading;
3
2
4 namespace Implab {
3 namespace Implab {
5 public class ActionTaskBase : AbstractPromise {
4 public class ActionTaskBase : AbstractTask {
6 readonly Action<Exception> m_cancel;
5 readonly Action<Exception> m_cancel;
7 readonly Action<Exception> m_error;
6 readonly Action<Exception> m_error;
8
7
9 int m_cancelationLock;
10
11 protected ActionTaskBase( Action<Exception> error, Action<Exception> cancel, bool autoCancellable) {
8 protected ActionTaskBase( Action<Exception> error, Action<Exception> cancel, bool autoCancellable) {
12 m_error = error;
9 m_error = error;
13 m_cancel = cancel;
10 m_cancel = cancel;
14 if (autoCancellable)
11 if (autoCancellable)
15 CancellationRequested(CancelOperation);
12 CancellationRequested(CancelOperation);
16 }
13 }
17
14
18 public void Reject(Exception error) {
15 public void Reject(Exception error) {
19 Safe.ArgumentNotNull(error, "error");
16 Safe.ArgumentNotNull(error, "error");
20 if (LockCancelation())
17 if (LockCancelation())
21 HandleErrorInternal(error);
18 HandleErrorInternal(error);
22 }
19 }
23
20
21 public override void CancelOperation(Exception reason) {
22 if (LockCancelation())
23 HandleCancelInternal(reason);
24 }
25
24 protected void HandleErrorInternal(Exception error) {
26 protected void HandleErrorInternal(Exception error) {
25 if (m_error != null) {
27 if (m_error != null) {
26 try {
28 try {
27 m_error(error);
29 m_error(error);
28 SetResult();
30 SetResult();
29 } catch(Exception err) {
31 } catch(Exception err) {
30 SetError(err);
32 SetErrorInternal(err);
31 }
33 }
32 } else {
34 } else {
33 SetError(error);
35 SetErrorInternal(error);
34 }
36 }
35 }
37 }
36
38
37 public override void CancelOperation(Exception reason) {
39 protected void HandleCancelInternal(Exception error) {
38 if (LockCancelation()) {
39 if (m_cancel != null) {
40 if (m_cancel != null) {
40 try {
41 try {
41 m_cancel(reason);
42 m_cancel(error);
42 SetResult();
43 SetResult();
43 } catch (Exception err) {
44 } catch(Exception err) {
44 HandleErrorInternal(err);
45 HandleErrorInternal(err);
45 }
46 }
46 } else {
47 } else {
47 SetCancelled(reason);
48 HandleErrorInternal(error ?? new OperationCanceledException());
49 }
48 }
50 }
49 }
51 }
50 }
52 }
51
53
52 protected bool LockCancelation() {
53 return 0 == Interlocked.CompareExchange(ref m_cancelationLock, 1, 0);
54 }
55 }
56 }
57
@@ -1,22 +1,24
1 using System;
1 using System;
2
2
3 namespace Implab {
3 namespace Implab {
4 public class ActionTask<T> : ActionTaskBase, IDeferred<T> {
4 public class ActionTask<T> : ActionTaskBase, IDeferred<T> {
5 readonly Action<T> m_task;
5 readonly Action<T> m_task;
6 public ActionTask(Action<T> task, Action<Exception> error, Action<Exception> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) {
6 public ActionTask(Action<T> task, Action<Exception> error, Action<Exception> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) {
7 m_task = task;
7 m_task = task;
8 }
8 }
9
9
10 public void Resolve(T value) {
10 public void Resolve(T value) {
11 if (m_task != null && LockCancelation()) {
11 if (m_task != null && LockCancelation()) {
12 try {
12 try {
13 m_task(value);
13 m_task(value);
14 SetResult();
14 SetResult();
15 } catch(OperationCanceledException reason) {
16 HandleCancelInternal(reason);
15 } catch(Exception err) {
17 } catch(Exception err) {
16 HandleErrorInternal(err);
18 HandleErrorInternal(err);
17 }
19 }
18 }
20 }
19 }
21 }
20 }
22 }
21 }
23 }
22
24
@@ -1,255 +1,257
1 using System;
1 using System;
2
2
3 namespace Implab.Components {
3 namespace Implab.Components {
4 public abstract class RunnableComponent : IDisposable, IRunnable, IInitializable {
4 public abstract class RunnableComponent : IDisposable, IRunnable, IInitializable {
5 enum Commands {
5 enum Commands {
6 Ok = 0,
6 Ok = 0,
7 Fail,
7 Fail,
8 Init,
8 Init,
9 Start,
9 Start,
10 Stop,
10 Stop,
11 Dispose,
11 Dispose,
12 Last = Dispose
12 Last = Dispose
13 }
13 }
14
14
15 class StateMachine {
15 class StateMachine {
16 static readonly ExecutionState[,] _transitions;
16 static readonly ExecutionState[,] _transitions;
17
17
18 static StateMachine() {
18 static StateMachine() {
19 _transitions = new ExecutionState[(int)ExecutionState.Last + 1, (int)Commands.Last + 1];
19 _transitions = new ExecutionState[(int)ExecutionState.Last + 1, (int)Commands.Last + 1];
20
20
21 Edge(ExecutionState.Created, ExecutionState.Initializing, Commands.Init);
21 Edge(ExecutionState.Created, ExecutionState.Initializing, Commands.Init);
22 Edge(ExecutionState.Created, ExecutionState.Disposed, Commands.Dispose);
22 Edge(ExecutionState.Created, ExecutionState.Disposed, Commands.Dispose);
23
23
24 Edge(ExecutionState.Initializing, ExecutionState.Ready, Commands.Ok);
24 Edge(ExecutionState.Initializing, ExecutionState.Ready, Commands.Ok);
25 Edge(ExecutionState.Initializing, ExecutionState.Failed, Commands.Fail);
25 Edge(ExecutionState.Initializing, ExecutionState.Failed, Commands.Fail);
26
26
27 Edge(ExecutionState.Ready, ExecutionState.Starting, Commands.Start);
27 Edge(ExecutionState.Ready, ExecutionState.Starting, Commands.Start);
28 Edge(ExecutionState.Ready, ExecutionState.Disposed, Commands.Dispose);
28 Edge(ExecutionState.Ready, ExecutionState.Disposed, Commands.Dispose);
29
29
30 Edge(ExecutionState.Starting, ExecutionState.Running, Commands.Ok);
30 Edge(ExecutionState.Starting, ExecutionState.Running, Commands.Ok);
31 Edge(ExecutionState.Starting, ExecutionState.Failed, Commands.Fail);
31 Edge(ExecutionState.Starting, ExecutionState.Failed, Commands.Fail);
32 Edge(ExecutionState.Starting, ExecutionState.Stopping, Commands.Stop);
32 Edge(ExecutionState.Starting, ExecutionState.Stopping, Commands.Stop);
33 Edge(ExecutionState.Starting, ExecutionState.Disposed, Commands.Dispose);
33 Edge(ExecutionState.Starting, ExecutionState.Disposed, Commands.Dispose);
34
34
35 Edge(ExecutionState.Running, ExecutionState.Failed, Commands.Fail);
35 Edge(ExecutionState.Running, ExecutionState.Failed, Commands.Fail);
36 Edge(ExecutionState.Running, ExecutionState.Stopping, Commands.Stop);
36 Edge(ExecutionState.Running, ExecutionState.Stopping, Commands.Stop);
37 Edge(ExecutionState.Running, ExecutionState.Disposed, Commands.Dispose);
37 Edge(ExecutionState.Running, ExecutionState.Disposed, Commands.Dispose);
38
38
39 Edge(ExecutionState.Stopping, ExecutionState.Failed, Commands.Fail);
39 Edge(ExecutionState.Stopping, ExecutionState.Failed, Commands.Fail);
40 Edge(ExecutionState.Stopping, ExecutionState.Disposed, Commands.Ok);
40 Edge(ExecutionState.Stopping, ExecutionState.Disposed, Commands.Ok);
41
41
42 Edge(ExecutionState.Failed, ExecutionState.Disposed, Commands.Dispose);
42 Edge(ExecutionState.Failed, ExecutionState.Disposed, Commands.Dispose);
43 }
43 }
44
44
45 static void Edge(ExecutionState s1, ExecutionState s2, Commands cmd) {
45 static void Edge(ExecutionState s1, ExecutionState s2, Commands cmd) {
46 _transitions[(int)s1, (int)cmd] = s2;
46 _transitions[(int)s1, (int)cmd] = s2;
47 }
47 }
48
48
49 public ExecutionState State {
49 public ExecutionState State {
50 get;
50 get;
51 private set;
51 private set;
52 }
52 }
53
53
54 public StateMachine(ExecutionState initial) {
54 public StateMachine(ExecutionState initial) {
55 State = initial;
55 State = initial;
56 }
56 }
57
57
58 public bool Move(Commands cmd) {
58 public bool Move(Commands cmd) {
59 var next = _transitions[(int)State, (int)cmd];
59 var next = _transitions[(int)State, (int)cmd];
60 if (next == ExecutionState.Undefined)
60 if (next == ExecutionState.Undefined)
61 return false;
61 return false;
62 State = next;
62 State = next;
63 return true;
63 return true;
64 }
64 }
65 }
65 }
66
66
67 IPromise m_pending;
67 IPromise m_pending;
68 Exception m_lastError;
68 Exception m_lastError;
69
69
70 readonly StateMachine m_stateMachine;
70 readonly StateMachine m_stateMachine;
71
71
72 protected RunnableComponent(bool initialized) {
72 protected RunnableComponent(bool initialized) {
73 m_stateMachine = new StateMachine(initialized ? ExecutionState.Ready : ExecutionState.Created);
73 m_stateMachine = new StateMachine(initialized ? ExecutionState.Ready : ExecutionState.Created);
74 }
74 }
75
75
76 protected virtual int DisposeTimeout {
76 protected virtual int DisposeTimeout {
77 get {
77 get {
78 return 10000;
78 return 10000;
79 }
79 }
80 }
80 }
81
81
82 void ThrowInvalidCommand(Commands cmd) {
82 void ThrowInvalidCommand(Commands cmd) {
83 if (m_stateMachine.State == ExecutionState.Disposed)
83 if (m_stateMachine.State == ExecutionState.Disposed)
84 throw new ObjectDisposedException(ToString());
84 throw new ObjectDisposedException(ToString());
85
85
86 throw new InvalidOperationException(String.Format("Commnd {0} is not allowed in the state {1}", cmd, m_stateMachine.State));
86 throw new InvalidOperationException(String.Format("Commnd {0} is not allowed in the state {1}", cmd, m_stateMachine.State));
87 }
87 }
88
88
89 void Move(Commands cmd) {
89 void Move(Commands cmd) {
90 if (!m_stateMachine.Move(cmd))
90 if (!m_stateMachine.Move(cmd))
91 ThrowInvalidCommand(cmd);
91 ThrowInvalidCommand(cmd);
92 }
92 }
93
93
94 void Invoke(Commands cmd, Action action) {
94 void Invoke(Commands cmd, Action action) {
95 lock (m_stateMachine)
95 lock (m_stateMachine)
96 Move(cmd);
96 Move(cmd);
97
97
98 try {
98 try {
99 action();
99 action();
100 lock(m_stateMachine)
100 lock(m_stateMachine)
101 Move(Commands.Ok);
101 Move(Commands.Ok);
102
102
103 } catch (Exception err) {
103 } catch (Exception err) {
104 lock (m_stateMachine) {
104 lock (m_stateMachine) {
105 Move(Commands.Fail);
105 Move(Commands.Fail);
106 m_lastError = err;
106 m_lastError = err;
107 }
107 }
108 throw;
108 throw;
109 }
109 }
110 }
110 }
111
111
112 IPromise InvokeAsync(Commands cmd, Func<IPromise> action, Action<IPromise, IDeferred> chain) {
112 IPromise InvokeAsync(Commands cmd, Func<IPromise> action, Action<IPromise, IDeferred> chain) {
113 IPromise promise = null;
113 IPromise promise = null;
114 IPromise prev;
114 IPromise prev;
115
115
116 var task = new ActionChainTask(action, null, null, true);
116 var task = new ActionChainTask(action, null, null, true);
117
117
118 lock (m_stateMachine) {
118 lock (m_stateMachine) {
119 Move(cmd);
119 Move(cmd);
120
120
121 prev = m_pending;
121 prev = m_pending;
122
122
123 promise = task.Then(
123 promise = task.Then(
124 () => {
124 () => {
125 lock(m_stateMachine) {
125 lock(m_stateMachine) {
126 if (m_pending == promise) {
126 if (m_pending == promise) {
127 Move(Commands.Ok);
127 Move(Commands.Ok);
128 m_pending = null;
128 m_pending = null;
129 }
129 }
130 }
130 }
131 }, e => {
131 }, e => {
132 lock(m_stateMachine) {
132 lock(m_stateMachine) {
133 if (m_pending == promise) {
133 if (m_pending == promise) {
134 Move(Commands.Fail);
134 Move(Commands.Fail);
135 m_pending = null;
135 m_pending = null;
136 m_lastError = e;
136 m_lastError = e;
137 }
137 }
138 }
138 }
139 throw new PromiseTransientException(e);
139 throw new PromiseTransientException(e);
140 },
141 r => {
142 // handle cancellation as exception
143 throw new OperationCanceledException("The operation has been cancelled", r);
144 }
140 }
145 );
141 );
146
142
147 m_pending = promise;
143 m_pending = promise;
148 }
144 }
149
145
150 if (prev == null)
146 if (prev == null)
151 task.Resolve();
147 task.Resolve();
152 else
148 else
153 chain(prev, task);
149 chain(prev, task);
154
150
155 return promise;
151 return promise;
156 }
152 }
157
153
158
154
159 #region IInitializable implementation
155 #region IInitializable implementation
160
156
161 public void Init() {
157 public void Init() {
162 Invoke(Commands.Init, OnInitialize);
158 Invoke(Commands.Init, OnInitialize);
163 }
159 }
164
160
165 protected virtual void OnInitialize() {
161 protected virtual void OnInitialize() {
166 }
162 }
167
163
168 #endregion
164 #endregion
169
165
170 #region IRunnable implementation
166 #region IRunnable implementation
171
167
172 public IPromise Start() {
168 public IPromise Start() {
173 return InvokeAsync(Commands.Start, OnStart, null);
169 return InvokeAsync(Commands.Start, OnStart, null);
174 }
170 }
175
171
176 protected virtual IPromise OnStart() {
172 protected virtual IPromise OnStart() {
177 return Promise.SUCCESS;
173 return Promise.SUCCESS;
178 }
174 }
179
175
180 public IPromise Stop() {
176 public IPromise Stop() {
181 return InvokeAsync(Commands.Stop, OnStop, StopPending).Then(Dispose);
177 return InvokeAsync(Commands.Stop, OnStop, StopPending).Then(Dispose);
182 }
178 }
183
179
184 protected virtual IPromise OnStop() {
180 protected virtual IPromise OnStop() {
185 return Promise.SUCCESS;
181 return Promise.SUCCESS;
186 }
182 }
187
183
188 /// <summary>
184 /// <summary>
189 /// Stops the current operation if one exists.
185 /// Stops the current operation if one exists.
190 /// </summary>
186 /// </summary>
191 /// <param name="current">Current.</param>
187 /// <param name="current">Current.</param>
192 /// <param name="stop">Stop.</param>
188 /// <param name="stop">Stop.</param>
193 protected virtual void StopPending(IPromise current, IDeferred stop) {
189 protected virtual void StopPending(IPromise current, IDeferred stop) {
194 if (current == null) {
190 if (current == null) {
195 stop.Resolve();
191 stop.Resolve();
196 } else {
192 } else {
197 current.On(stop.Resolve, stop.Reject, e => stop.Resolve());
193 // связваСм Ρ‚Π΅ΠΊΡƒΡ‰ΡƒΡŽ ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΡŽ с ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠ΅ΠΉ остановки
194 current.On(
195 stop.Resolve, // Ссли тСкущая опСрация Π·Π°Π²Π΅Ρ€Ρ‰ΠΈΠ»Π°ΡΡŒ, Ρ‚ΠΎ ΠΌΠΎΠΆΠ½ΠΎ Π½Π°Ρ‡ΠΈΠ½Π°Ρ‚ΡŒ остановку
196 stop.Reject, // Ссли тСкущая опСрация Π΄Π°Π»Π° ΠΎΡˆΠΈΠ±ΠΊΡƒ - Ρ‚ΠΎ всС ΠΏΠ»ΠΎΡ…ΠΎ, нСльзя ΠΏΡ€ΠΎΠ΄ΠΎΠ»ΠΆΠ°Ρ‚ΡŒ
197 e => stop.Resolve() // Ссли тСкущая ΠΎΡ‚ΠΌΠ΅Π½ΠΈΠ»Π°ΡΡŒ, Ρ‚ΠΎ ΠΌΠΎΠΆΠ½ΠΎ Π½Π°Ρ‡ΠΈΠ½Π°Ρ‚ΡŒ остановку
198 );
199 // посылаСм Ρ‚Π΅ΠΊΡƒΡ‰Π΅ΠΉ ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ сигнал остановки
198 current.Cancel();
200 current.Cancel();
199 }
201 }
200 }
202 }
201
203
202 public ExecutionState State {
204 public ExecutionState State {
203 get {
205 get {
204 return m_stateMachine.State;
206 return m_stateMachine.State;
205 }
207 }
206 }
208 }
207
209
208 public Exception LastError {
210 public Exception LastError {
209 get {
211 get {
210 return m_lastError;
212 return m_lastError;
211 }
213 }
212 }
214 }
213
215
214 #endregion
216 #endregion
215
217
216 #region IDisposable implementation
218 #region IDisposable implementation
217
219
218 public void Dispose() {
220 public void Dispose() {
219 IPromise pending;
221 IPromise pending;
220 lock (m_stateMachine) {
222 lock (m_stateMachine) {
221 if (m_stateMachine.State == ExecutionState.Disposed)
223 if (m_stateMachine.State == ExecutionState.Disposed)
222 return;
224 return;
223
225
224 Move(Commands.Dispose);
226 Move(Commands.Dispose);
225
227
226 GC.SuppressFinalize(this);
228 GC.SuppressFinalize(this);
227
229
228 pending = m_pending;
230 pending = m_pending;
229 m_pending = null;
231 m_pending = null;
230 }
232 }
231 if (pending != null) {
233 if (pending != null) {
232 pending.Cancel();
234 pending.Cancel();
233 pending.Timeout(DisposeTimeout).On(
235 pending.Timeout(DisposeTimeout).On(
234 () => Dispose(true, null),
236 () => Dispose(true, null),
235 err => Dispose(true, err),
237 err => Dispose(true, err),
236 reason => Dispose(true, new OperationCanceledException("The operation is cancelled", reason))
238 reason => Dispose(true, new OperationCanceledException("The operation is cancelled", reason))
237 );
239 );
238 } else {
240 } else {
239 Dispose(true, m_lastError);
241 Dispose(true, m_lastError);
240 }
242 }
241 }
243 }
242
244
243 ~RunnableComponent() {
245 ~RunnableComponent() {
244 Dispose(false, null);
246 Dispose(false, null);
245 }
247 }
246
248
247 #endregion
249 #endregion
248
250
249 protected virtual void Dispose(bool disposing, Exception lastError) {
251 protected virtual void Dispose(bool disposing, Exception lastError) {
250
252
251 }
253 }
252
254
253 }
255 }
254 }
256 }
255
257
@@ -1,24 +1,26
1 using System;
1 using System;
2
2
3 namespace Implab {
3 namespace Implab {
4 public class FuncChainTask<TResult> : FuncChainTaskBase<TResult>, IDeferred {
4 public class FuncChainTask<TResult> : FuncChainTaskBase<TResult>, IDeferred {
5 readonly Func<IPromise<TResult>> m_task;
5 readonly Func<IPromise<TResult>> m_task;
6
6
7 public FuncChainTask(Func<IPromise<TResult>> task, Func<Exception, IPromise<TResult>> error, Func<Exception, IPromise<TResult>> cancel, bool autoCancellable)
7 public FuncChainTask(Func<IPromise<TResult>> task, Func<Exception, IPromise<TResult>> error, Func<Exception, IPromise<TResult>> cancel, bool autoCancellable)
8 : base(error, cancel, autoCancellable) {
8 : base(error, cancel, autoCancellable) {
9 m_task = task;
9 m_task = task;
10 }
10 }
11
11
12 public void Resolve() {
12 public void Resolve() {
13 if (m_task != null && LockCancelation()) {
13 if (m_task != null && LockCancelation()) {
14 try {
14 try {
15 var operation = m_task();
15 var operation = m_task();
16 operation.On(SetResult, HandleErrorInternal, SetCancelled);
16 operation.On(SetResult, HandleErrorInternal, HandleCancelInternal);
17 CancellationRequested(operation.Cancel);
17 CancellationRequested(operation.Cancel);
18 } catch (OperationCanceledException reason) {
19 HandleCancelInternal(reason);
18 } catch (Exception err) {
20 } catch (Exception err) {
19 HandleErrorInternal(err);
21 HandleErrorInternal(err);
20 }
22 }
21 }
23 }
22 }
24 }
23 }
25 }
24 } No newline at end of file
26 }
@@ -1,58 +1,54
1 using System;
1 using System;
2 using System.Threading;
3
2
4 namespace Implab {
3 namespace Implab {
5 public class FuncChainTaskBase<TResult> : AbstractPromise<TResult> {
4 public class FuncChainTaskBase<TResult> : AbstractTask<TResult> {
6 readonly Func<Exception, IPromise<TResult>> m_error;
5 readonly Func<Exception, IPromise<TResult>> m_error;
7 readonly Func<Exception, IPromise<TResult>> m_cancel;
6 readonly Func<Exception, IPromise<TResult>> m_cancel;
8
7
9 int m_cancelationLock;
10
11 protected FuncChainTaskBase( Func<Exception, IPromise<TResult>> error, Func<Exception, IPromise<TResult>> cancel, bool autoCancellable) {
8 protected FuncChainTaskBase( Func<Exception, IPromise<TResult>> error, Func<Exception, IPromise<TResult>> cancel, bool autoCancellable) {
12 m_error = error;
9 m_error = error;
13 m_cancel = cancel;
10 m_cancel = cancel;
14 if (autoCancellable)
11 if (autoCancellable)
15 CancellationRequested(CancelOperation);
12 CancellationRequested(CancelOperation);
16 }
13 }
17
14
18 public void Reject(Exception error) {
15 public void Reject(Exception error) {
19 if (LockCancelation())
16 if (LockCancelation())
20 HandleErrorInternal(error);
17 HandleErrorInternal(error);
21 }
18 }
22
19
23 public override void CancelOperation(Exception reason) {
20 public override void CancelOperation(Exception reason) {
24 if (LockCancelation()) {
21 if (LockCancelation())
25 if (m_cancel != null) {
22 HandleCancelInternal(reason);
26 try {
27 m_cancel(reason).On(SetResult, HandleErrorInternal, SetCancelled);
28 } catch (Exception err) {
29 HandleErrorInternal(err);
30 }
31 } else {
32 SetCancelled(reason);
33 }
34 }
35
36 }
23 }
37
24
38 protected void HandleErrorInternal(Exception error) {
25 protected void HandleErrorInternal(Exception error) {
39 if (m_error != null) {
26 if (m_error != null) {
40 try {
27 try {
41 var operation = m_error(error);
28 var p = m_error(error);
42
29 p.On(SetResult, SetErrorInternal, SetCancelledInternal);
43 operation.On(SetResult, SetError, SetCancelled);
30 CancellationRequested(p.Cancel);
44 CancellationRequested(operation.Cancel);
45 } catch(Exception err) {
31 } catch(Exception err) {
46 SetError(err);
32 SetErrorInternal(err);
47 }
33 }
48 } else {
34 } else {
49 SetError(error);
35 SetErrorInternal(error);
50 }
36 }
51 }
37 }
52
38
53 protected bool LockCancelation() {
39 protected void HandleCancelInternal(Exception reason) {
54 return 0 == Interlocked.CompareExchange(ref m_cancelationLock, 1, 0);
40 if (m_cancel != null) {
41 try {
42 var p = m_cancel(reason);
43 p.On(SetResult, HandleErrorInternal, SetCancelledInternal);
44 CancellationRequested(p.Cancel);
45 } catch (Exception err) {
46 HandleErrorInternal(err);
47 }
48 } else {
49 HandleErrorInternal(reason ?? new OperationCanceledException());
50 }
55 }
51 }
56 }
52 }
57 }
53 }
58
54
@@ -1,23 +1,25
1 using System;
1 using System;
2
2
3 namespace Implab {
3 namespace Implab {
4 public class FuncChainTask<TArg,TResult> : FuncChainTaskBase<TResult>, IDeferred<TArg> {
4 public class FuncChainTask<TArg,TResult> : FuncChainTaskBase<TResult>, IDeferred<TArg> {
5 readonly Func<TArg, IPromise<TResult>> m_task;
5 readonly Func<TArg, IPromise<TResult>> m_task;
6
6
7 public FuncChainTask(Func<TArg, IPromise<TResult>> task, Func<Exception, IPromise<TResult>> error, Func<Exception, IPromise<TResult>> cancel, bool autoCancellable) : base(error, cancel, autoCancellable){
7 public FuncChainTask(Func<TArg, IPromise<TResult>> task, Func<Exception, IPromise<TResult>> error, Func<Exception, IPromise<TResult>> cancel, bool autoCancellable) : base(error, cancel, autoCancellable){
8 m_task = task;
8 m_task = task;
9 }
9 }
10
10
11 public void Resolve(TArg value) {
11 public void Resolve(TArg value) {
12 if (m_task != null && LockCancelation()) {
12 if (m_task != null && LockCancelation()) {
13 try {
13 try {
14 var operation = m_task(value);
14 var operation = m_task(value);
15 operation.On(SetResult, HandleErrorInternal, SetCancelled);
15 operation.On(SetResult, HandleErrorInternal, SetCancelled);
16 CancellationRequested(operation.Cancel);
16 CancellationRequested(operation.Cancel);
17 } catch (OperationCanceledException reason) {
18 HandleCancelInternal(reason);
17 } catch (Exception err) {
19 } catch (Exception err) {
18 HandleErrorInternal(err);
20 HandleErrorInternal(err);
19 }
21 }
20 }
22 }
21 }
23 }
22 }
24 }
23 } No newline at end of file
25 }
@@ -1,23 +1,25
1 using System;
1 using System;
2 using System.Threading;
2 using System.Threading;
3
3
4 namespace Implab {
4 namespace Implab {
5 public class FuncTask<T> : FuncTaskBase<T>, IDeferred {
5 public class FuncTask<T> : FuncTaskBase<T>, IDeferred {
6 readonly Func<T> m_task;
6 readonly Func<T> m_task;
7
7
8 public FuncTask(Func<T> task, Func<Exception, T> error, Func<Exception, T> cancel, bool autoCancellable) : base(error, cancel, autoCancellable) {
8 public FuncTask(Func<T> task, Func<Exception, T> error, Func<Exception, T> cancel, bool autoCancellable) : base(error, cancel, autoCancellable) {
9 m_task = task;
9 m_task = task;
10 }
10 }
11
11
12 public void Resolve() {
12 public void Resolve() {
13 if (m_task != null && LockCancelation()) {
13 if (m_task != null && LockCancelation()) {
14 try {
14 try {
15 SetResult(m_task());
15 SetResult(m_task());
16 } catch(OperationCanceledException reason) {
17 HandleCancelInternal(reason);
16 } catch(Exception err) {
18 } catch(Exception err) {
17 HandleErrorInternal(err);
19 HandleErrorInternal(err);
18 }
20 }
19 }
21 }
20 }
22 }
21 }
23 }
22 }
24 }
23
25
@@ -1,55 +1,52
1 using System;
1 using System;
2 using System.Threading;
3
2
4 namespace Implab {
3 namespace Implab {
5 public class FuncTaskBase<TResult> : AbstractPromise<TResult> {
4 public class FuncTaskBase<TResult> : AbstractTask<TResult> {
6 readonly Func<Exception, TResult> m_cancel;
5 readonly Func<Exception, TResult> m_cancel;
7 readonly Func<Exception, TResult> m_error;
6 readonly Func<Exception, TResult> m_error;
8
7
9 int m_cancelationLock;
10
11 protected FuncTaskBase( Func<Exception, TResult> error, Func<Exception, TResult> cancel, bool autoCancellable) {
8 protected FuncTaskBase( Func<Exception, TResult> error, Func<Exception, TResult> cancel, bool autoCancellable) {
12 m_error = error;
9 m_error = error;
13 m_cancel = cancel;
10 m_cancel = cancel;
14 if (autoCancellable)
11 if (autoCancellable)
15 CancellationRequested(CancelOperation);
12 CancellationRequested(CancelOperation);
16 }
13 }
17
14
18 public void Reject(Exception error) {
15 public void Reject(Exception error) {
19 Safe.ArgumentNotNull(error, "error");
16 Safe.ArgumentNotNull(error, "error");
20 if (LockCancelation())
17 if (LockCancelation())
21 HandleErrorInternal(error);
18 HandleErrorInternal(error);
22 }
19 }
23
20
24 protected void HandleErrorInternal(Exception error) {
21 protected void HandleErrorInternal(Exception error) {
25 if (m_error != null) {
22 if (m_error != null) {
26 try {
23 try {
27 SetResult(m_error(error));
24 SetResult(m_error(error));
28 } catch(Exception err) {
25 } catch(Exception err) {
29 SetError(err);
26 SetErrorInternal(err);
30 }
27 }
31 } else {
28 } else {
32 SetError(error);
29 SetErrorInternal(error);
33 }
30 }
34 }
31 }
35
32
36 public override void CancelOperation(Exception reason) {
33 public override void CancelOperation(Exception reason) {
37 if (LockCancelation()) {
34 if (LockCancelation())
35 HandleCancelInternal(reason);
36 }
37
38 protected void HandleCancelInternal(Exception reason) {
38 if (m_cancel != null) {
39 if (m_cancel != null) {
39 try {
40 try {
40 SetResult(m_cancel(reason));
41 SetResult(m_cancel(reason));
41 } catch (Exception err) {
42 } catch (Exception err) {
42 HandleErrorInternal(err);
43 HandleErrorInternal(err);
43 }
44 }
44 } else {
45 } else {
45 SetCancelled(reason);
46 HandleErrorInternal(reason ?? new OperationCanceledException());
46 }
47 }
47 }
48 }
48 }
49
49
50 protected bool LockCancelation() {
51 return 0 == Interlocked.CompareExchange(ref m_cancelationLock, 1, 0);
52 }
53 }
50 }
54 }
51 }
55
52
@@ -1,22 +1,24
1 using System;
1 using System;
2
2
3 namespace Implab {
3 namespace Implab {
4 public class FuncTask<TArg, TResult> : FuncTaskBase<TResult>, IDeferred<TArg> {
4 public class FuncTask<TArg, TResult> : FuncTaskBase<TResult>, IDeferred<TArg> {
5 readonly Func<TArg, TResult> m_task;
5 readonly Func<TArg, TResult> m_task;
6
6
7 public FuncTask(Func<TArg, TResult> task, Func<Exception, TResult> error,Func<Exception, TResult> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) {
7 public FuncTask(Func<TArg, TResult> task, Func<Exception, TResult> error,Func<Exception, TResult> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) {
8 m_task = task;
8 m_task = task;
9 }
9 }
10
10
11 public void Resolve(TArg value) {
11 public void Resolve(TArg value) {
12 if (m_task != null && LockCancelation()) {
12 if (m_task != null && LockCancelation()) {
13 try {
13 try {
14 SetResult(m_task(value));
14 SetResult(m_task(value));
15 } catch(OperationCanceledException reason) {
16 HandleCancelInternal(reason);
15 } catch (Exception err) {
17 } catch(Exception err) {
16 HandleErrorInternal(err);
18 HandleErrorInternal(err);
17 }
19 }
18 }
20 }
19 }
21 }
20 }
22 }
21 }
23 }
22
24
@@ -1,274 +1,276
1 ο»Ώ<?xml version="1.0" encoding="utf-8"?>
1 ο»Ώ<?xml version="1.0" encoding="utf-8"?>
2 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <PropertyGroup>
3 <PropertyGroup>
4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6 <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid>
6 <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid>
7 <OutputType>Library</OutputType>
7 <OutputType>Library</OutputType>
8 <RootNamespace>Implab</RootNamespace>
8 <RootNamespace>Implab</RootNamespace>
9 <AssemblyName>Implab</AssemblyName>
9 <AssemblyName>Implab</AssemblyName>
10 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
10 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
11 <ReleaseVersion>0.2</ReleaseVersion>
11 <ReleaseVersion>0.2</ReleaseVersion>
12 <ProductVersion>8.0.30703</ProductVersion>
12 <ProductVersion>8.0.30703</ProductVersion>
13 <SchemaVersion>2.0</SchemaVersion>
13 <SchemaVersion>2.0</SchemaVersion>
14 </PropertyGroup>
14 </PropertyGroup>
15 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16 <DebugSymbols>true</DebugSymbols>
16 <DebugSymbols>true</DebugSymbols>
17 <DebugType>full</DebugType>
17 <DebugType>full</DebugType>
18 <Optimize>false</Optimize>
18 <Optimize>false</Optimize>
19 <OutputPath>bin\Debug</OutputPath>
19 <OutputPath>bin\Debug</OutputPath>
20 <DefineConstants>TRACE;DEBUG;</DefineConstants>
20 <DefineConstants>TRACE;DEBUG;</DefineConstants>
21 <ErrorReport>prompt</ErrorReport>
21 <ErrorReport>prompt</ErrorReport>
22 <WarningLevel>4</WarningLevel>
22 <WarningLevel>4</WarningLevel>
23 <ConsolePause>false</ConsolePause>
23 <ConsolePause>false</ConsolePause>
24 <RunCodeAnalysis>true</RunCodeAnalysis>
24 <RunCodeAnalysis>true</RunCodeAnalysis>
25 </PropertyGroup>
25 </PropertyGroup>
26 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27 <DebugType>full</DebugType>
27 <DebugType>full</DebugType>
28 <Optimize>true</Optimize>
28 <Optimize>true</Optimize>
29 <OutputPath>bin\Release</OutputPath>
29 <OutputPath>bin\Release</OutputPath>
30 <ErrorReport>prompt</ErrorReport>
30 <ErrorReport>prompt</ErrorReport>
31 <WarningLevel>4</WarningLevel>
31 <WarningLevel>4</WarningLevel>
32 <ConsolePause>false</ConsolePause>
32 <ConsolePause>false</ConsolePause>
33 </PropertyGroup>
33 </PropertyGroup>
34 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
34 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
35 <DebugSymbols>true</DebugSymbols>
35 <DebugSymbols>true</DebugSymbols>
36 <DebugType>full</DebugType>
36 <DebugType>full</DebugType>
37 <Optimize>false</Optimize>
37 <Optimize>false</Optimize>
38 <OutputPath>bin\Debug</OutputPath>
38 <OutputPath>bin\Debug</OutputPath>
39 <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants>
39 <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants>
40 <ErrorReport>prompt</ErrorReport>
40 <ErrorReport>prompt</ErrorReport>
41 <WarningLevel>4</WarningLevel>
41 <WarningLevel>4</WarningLevel>
42 <RunCodeAnalysis>true</RunCodeAnalysis>
42 <RunCodeAnalysis>true</RunCodeAnalysis>
43 <ConsolePause>false</ConsolePause>
43 <ConsolePause>false</ConsolePause>
44 </PropertyGroup>
44 </PropertyGroup>
45 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
45 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
46 <Optimize>true</Optimize>
46 <Optimize>true</Optimize>
47 <OutputPath>bin\Release</OutputPath>
47 <OutputPath>bin\Release</OutputPath>
48 <ErrorReport>prompt</ErrorReport>
48 <ErrorReport>prompt</ErrorReport>
49 <WarningLevel>4</WarningLevel>
49 <WarningLevel>4</WarningLevel>
50 <ConsolePause>false</ConsolePause>
50 <ConsolePause>false</ConsolePause>
51 <DefineConstants>NET_4_5</DefineConstants>
51 <DefineConstants>NET_4_5</DefineConstants>
52 </PropertyGroup>
52 </PropertyGroup>
53 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|AnyCPU' ">
53 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|AnyCPU' ">
54 <DebugSymbols>true</DebugSymbols>
54 <DebugSymbols>true</DebugSymbols>
55 <DebugType>full</DebugType>
55 <DebugType>full</DebugType>
56 <Optimize>false</Optimize>
56 <Optimize>false</Optimize>
57 <OutputPath>bin\Debug</OutputPath>
57 <OutputPath>bin\Debug</OutputPath>
58 <DefineConstants>TRACE;DEBUG;NET_4_5;MONO</DefineConstants>
58 <DefineConstants>TRACE;DEBUG;NET_4_5;MONO</DefineConstants>
59 <ErrorReport>prompt</ErrorReport>
59 <ErrorReport>prompt</ErrorReport>
60 <WarningLevel>4</WarningLevel>
60 <WarningLevel>4</WarningLevel>
61 <RunCodeAnalysis>true</RunCodeAnalysis>
61 <RunCodeAnalysis>true</RunCodeAnalysis>
62 <ConsolePause>false</ConsolePause>
62 <ConsolePause>false</ConsolePause>
63 </PropertyGroup>
63 </PropertyGroup>
64 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|AnyCPU' ">
64 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|AnyCPU' ">
65 <Optimize>true</Optimize>
65 <Optimize>true</Optimize>
66 <OutputPath>bin\Release</OutputPath>
66 <OutputPath>bin\Release</OutputPath>
67 <DefineConstants>NET_4_5;MONO;</DefineConstants>
67 <DefineConstants>NET_4_5;MONO;</DefineConstants>
68 <ErrorReport>prompt</ErrorReport>
68 <ErrorReport>prompt</ErrorReport>
69 <WarningLevel>4</WarningLevel>
69 <WarningLevel>4</WarningLevel>
70 <ConsolePause>false</ConsolePause>
70 <ConsolePause>false</ConsolePause>
71 </PropertyGroup>
71 </PropertyGroup>
72 <ItemGroup>
72 <ItemGroup>
73 <Reference Include="System" />
73 <Reference Include="System" />
74 <Reference Include="System.Xml" />
74 <Reference Include="System.Xml" />
75 <Reference Include="mscorlib" />
75 <Reference Include="mscorlib" />
76 </ItemGroup>
76 </ItemGroup>
77 <ItemGroup>
77 <ItemGroup>
78 <Compile Include="CustomEqualityComparer.cs" />
78 <Compile Include="CustomEqualityComparer.cs" />
79 <Compile Include="Diagnostics\ConsoleTraceListener.cs" />
79 <Compile Include="Diagnostics\ConsoleTraceListener.cs" />
80 <Compile Include="Diagnostics\EventText.cs" />
80 <Compile Include="Diagnostics\EventText.cs" />
81 <Compile Include="Diagnostics\LogChannel.cs" />
81 <Compile Include="Diagnostics\LogChannel.cs" />
82 <Compile Include="Diagnostics\LogicalOperation.cs" />
82 <Compile Include="Diagnostics\LogicalOperation.cs" />
83 <Compile Include="Diagnostics\TextFileListener.cs" />
83 <Compile Include="Diagnostics\TextFileListener.cs" />
84 <Compile Include="Diagnostics\TraceLog.cs" />
84 <Compile Include="Diagnostics\TraceLog.cs" />
85 <Compile Include="Diagnostics\TraceEvent.cs" />
85 <Compile Include="Diagnostics\TraceEvent.cs" />
86 <Compile Include="Diagnostics\TraceEventType.cs" />
86 <Compile Include="Diagnostics\TraceEventType.cs" />
87 <Compile Include="ICancellable.cs" />
87 <Compile Include="ICancellable.cs" />
88 <Compile Include="IProgressHandler.cs" />
88 <Compile Include="IProgressHandler.cs" />
89 <Compile Include="IProgressNotifier.cs" />
89 <Compile Include="IProgressNotifier.cs" />
90 <Compile Include="IPromiseT.cs" />
90 <Compile Include="IPromiseT.cs" />
91 <Compile Include="IPromise.cs" />
91 <Compile Include="IPromise.cs" />
92 <Compile Include="IServiceLocator.cs" />
92 <Compile Include="IServiceLocator.cs" />
93 <Compile Include="ITaskController.cs" />
93 <Compile Include="ITaskController.cs" />
94 <Compile Include="Parallels\DispatchPool.cs" />
94 <Compile Include="Parallels\DispatchPool.cs" />
95 <Compile Include="Parallels\ArrayTraits.cs" />
95 <Compile Include="Parallels\ArrayTraits.cs" />
96 <Compile Include="Parallels\MTQueue.cs" />
96 <Compile Include="Parallels\MTQueue.cs" />
97 <Compile Include="Parallels\WorkerPool.cs" />
97 <Compile Include="Parallels\WorkerPool.cs" />
98 <Compile Include="ProgressInitEventArgs.cs" />
98 <Compile Include="ProgressInitEventArgs.cs" />
99 <Compile Include="Properties\AssemblyInfo.cs" />
99 <Compile Include="Properties\AssemblyInfo.cs" />
100 <Compile Include="Parallels\AsyncPool.cs" />
100 <Compile Include="Parallels\AsyncPool.cs" />
101 <Compile Include="Safe.cs" />
101 <Compile Include="Safe.cs" />
102 <Compile Include="ValueEventArgs.cs" />
102 <Compile Include="ValueEventArgs.cs" />
103 <Compile Include="PromiseExtensions.cs" />
103 <Compile Include="PromiseExtensions.cs" />
104 <Compile Include="SyncContextPromise.cs" />
104 <Compile Include="SyncContextPromise.cs" />
105 <Compile Include="Diagnostics\OperationContext.cs" />
105 <Compile Include="Diagnostics\OperationContext.cs" />
106 <Compile Include="Diagnostics\TraceContext.cs" />
106 <Compile Include="Diagnostics\TraceContext.cs" />
107 <Compile Include="Diagnostics\LogEventArgs.cs" />
107 <Compile Include="Diagnostics\LogEventArgs.cs" />
108 <Compile Include="Diagnostics\LogEventArgsT.cs" />
108 <Compile Include="Diagnostics\LogEventArgsT.cs" />
109 <Compile Include="Diagnostics\Extensions.cs" />
109 <Compile Include="Diagnostics\Extensions.cs" />
110 <Compile Include="PromiseEventType.cs" />
110 <Compile Include="PromiseEventType.cs" />
111 <Compile Include="Parallels\AsyncQueue.cs" />
111 <Compile Include="Parallels\AsyncQueue.cs" />
112 <Compile Include="PromiseT.cs" />
112 <Compile Include="PromiseT.cs" />
113 <Compile Include="IDeferred.cs" />
113 <Compile Include="IDeferred.cs" />
114 <Compile Include="IDeferredT.cs" />
114 <Compile Include="IDeferredT.cs" />
115 <Compile Include="Promise.cs" />
115 <Compile Include="Promise.cs" />
116 <Compile Include="PromiseTransientException.cs" />
116 <Compile Include="PromiseTransientException.cs" />
117 <Compile Include="Parallels\Signal.cs" />
117 <Compile Include="Parallels\Signal.cs" />
118 <Compile Include="Parallels\SharedLock.cs" />
118 <Compile Include="Parallels\SharedLock.cs" />
119 <Compile Include="Diagnostics\ILogWriter.cs" />
119 <Compile Include="Diagnostics\ILogWriter.cs" />
120 <Compile Include="Diagnostics\ListenerBase.cs" />
120 <Compile Include="Diagnostics\ListenerBase.cs" />
121 <Compile Include="Parallels\BlockingQueue.cs" />
121 <Compile Include="Parallels\BlockingQueue.cs" />
122 <Compile Include="AbstractEvent.cs" />
122 <Compile Include="AbstractEvent.cs" />
123 <Compile Include="AbstractPromise.cs" />
123 <Compile Include="AbstractPromise.cs" />
124 <Compile Include="AbstractPromiseT.cs" />
124 <Compile Include="AbstractPromiseT.cs" />
125 <Compile Include="FuncTask.cs" />
125 <Compile Include="FuncTask.cs" />
126 <Compile Include="FuncTaskBase.cs" />
126 <Compile Include="FuncTaskBase.cs" />
127 <Compile Include="FuncTaskT.cs" />
127 <Compile Include="FuncTaskT.cs" />
128 <Compile Include="ActionChainTaskBase.cs" />
128 <Compile Include="ActionChainTaskBase.cs" />
129 <Compile Include="ActionChainTask.cs" />
129 <Compile Include="ActionChainTask.cs" />
130 <Compile Include="ActionChainTaskT.cs" />
130 <Compile Include="ActionChainTaskT.cs" />
131 <Compile Include="FuncChainTaskBase.cs" />
131 <Compile Include="FuncChainTaskBase.cs" />
132 <Compile Include="FuncChainTask.cs" />
132 <Compile Include="FuncChainTask.cs" />
133 <Compile Include="FuncChainTaskT.cs" />
133 <Compile Include="FuncChainTaskT.cs" />
134 <Compile Include="ActionTaskBase.cs" />
134 <Compile Include="ActionTaskBase.cs" />
135 <Compile Include="ActionTask.cs" />
135 <Compile Include="ActionTask.cs" />
136 <Compile Include="ActionTaskT.cs" />
136 <Compile Include="ActionTaskT.cs" />
137 <Compile Include="ICancellationToken.cs" />
137 <Compile Include="ICancellationToken.cs" />
138 <Compile Include="SuccessPromise.cs" />
138 <Compile Include="SuccessPromise.cs" />
139 <Compile Include="SuccessPromiseT.cs" />
139 <Compile Include="SuccessPromiseT.cs" />
140 <Compile Include="PromiseAwaiterT.cs" />
140 <Compile Include="PromiseAwaiterT.cs" />
141 <Compile Include="PromiseAwaiter.cs" />
141 <Compile Include="PromiseAwaiter.cs" />
142 <Compile Include="Components\ComponentContainer.cs" />
142 <Compile Include="Components\ComponentContainer.cs" />
143 <Compile Include="Components\Disposable.cs" />
143 <Compile Include="Components\Disposable.cs" />
144 <Compile Include="Components\DisposablePool.cs" />
144 <Compile Include="Components\DisposablePool.cs" />
145 <Compile Include="Components\ObjectPool.cs" />
145 <Compile Include="Components\ObjectPool.cs" />
146 <Compile Include="Components\ServiceLocator.cs" />
146 <Compile Include="Components\ServiceLocator.cs" />
147 <Compile Include="Components\IInitializable.cs" />
147 <Compile Include="Components\IInitializable.cs" />
148 <Compile Include="TaskController.cs" />
148 <Compile Include="TaskController.cs" />
149 <Compile Include="Components\App.cs" />
149 <Compile Include="Components\App.cs" />
150 <Compile Include="Components\IRunnable.cs" />
150 <Compile Include="Components\IRunnable.cs" />
151 <Compile Include="Components\ExecutionState.cs" />
151 <Compile Include="Components\ExecutionState.cs" />
152 <Compile Include="Components\RunnableComponent.cs" />
152 <Compile Include="Components\RunnableComponent.cs" />
153 <Compile Include="Components\IFactory.cs" />
153 <Compile Include="Components\IFactory.cs" />
154 <Compile Include="Automaton\IAlphabet.cs" />
154 <Compile Include="Automaton\IAlphabet.cs" />
155 <Compile Include="Automaton\ParserException.cs" />
155 <Compile Include="Automaton\ParserException.cs" />
156 <Compile Include="Automaton\IndexedAlphabetBase.cs" />
156 <Compile Include="Automaton\IndexedAlphabetBase.cs" />
157 <Compile Include="Automaton\IAlphabetBuilder.cs" />
157 <Compile Include="Automaton\IAlphabetBuilder.cs" />
158 <Compile Include="Automaton\RegularExpressions\AltToken.cs" />
158 <Compile Include="Automaton\RegularExpressions\AltToken.cs" />
159 <Compile Include="Automaton\RegularExpressions\BinaryToken.cs" />
159 <Compile Include="Automaton\RegularExpressions\BinaryToken.cs" />
160 <Compile Include="Automaton\RegularExpressions\CatToken.cs" />
160 <Compile Include="Automaton\RegularExpressions\CatToken.cs" />
161 <Compile Include="Automaton\RegularExpressions\StarToken.cs" />
161 <Compile Include="Automaton\RegularExpressions\StarToken.cs" />
162 <Compile Include="Automaton\RegularExpressions\SymbolToken.cs" />
162 <Compile Include="Automaton\RegularExpressions\SymbolToken.cs" />
163 <Compile Include="Automaton\RegularExpressions\EmptyToken.cs" />
163 <Compile Include="Automaton\RegularExpressions\EmptyToken.cs" />
164 <Compile Include="Automaton\RegularExpressions\Token.cs" />
164 <Compile Include="Automaton\RegularExpressions\Token.cs" />
165 <Compile Include="Automaton\RegularExpressions\IVisitor.cs" />
165 <Compile Include="Automaton\RegularExpressions\IVisitor.cs" />
166 <Compile Include="Automaton\AutomatonTransition.cs" />
166 <Compile Include="Automaton\AutomatonTransition.cs" />
167 <Compile Include="Formats\JSON\JSONElementContext.cs" />
167 <Compile Include="Formats\JSON\JSONElementContext.cs" />
168 <Compile Include="Formats\JSON\JSONElementType.cs" />
168 <Compile Include="Formats\JSON\JSONElementType.cs" />
169 <Compile Include="Formats\JSON\JSONGrammar.cs" />
169 <Compile Include="Formats\JSON\JSONGrammar.cs" />
170 <Compile Include="Formats\JSON\JSONParser.cs" />
170 <Compile Include="Formats\JSON\JSONParser.cs" />
171 <Compile Include="Formats\JSON\JSONScanner.cs" />
171 <Compile Include="Formats\JSON\JSONScanner.cs" />
172 <Compile Include="Formats\JSON\JsonTokenType.cs" />
172 <Compile Include="Formats\JSON\JsonTokenType.cs" />
173 <Compile Include="Formats\JSON\JSONWriter.cs" />
173 <Compile Include="Formats\JSON\JSONWriter.cs" />
174 <Compile Include="Formats\JSON\JSONXmlReader.cs" />
174 <Compile Include="Formats\JSON\JSONXmlReader.cs" />
175 <Compile Include="Formats\JSON\JSONXmlReaderOptions.cs" />
175 <Compile Include="Formats\JSON\JSONXmlReaderOptions.cs" />
176 <Compile Include="Formats\JSON\StringTranslator.cs" />
176 <Compile Include="Formats\JSON\StringTranslator.cs" />
177 <Compile Include="Automaton\MapAlphabet.cs" />
177 <Compile Include="Automaton\MapAlphabet.cs" />
178 <Compile Include="Formats\CharAlphabet.cs" />
178 <Compile Include="Formats\CharAlphabet.cs" />
179 <Compile Include="Formats\ByteAlphabet.cs" />
179 <Compile Include="Formats\ByteAlphabet.cs" />
180 <Compile Include="Automaton\IDFATable.cs" />
180 <Compile Include="Automaton\IDFATable.cs" />
181 <Compile Include="Automaton\IDFATableBuilder.cs" />
181 <Compile Include="Automaton\IDFATableBuilder.cs" />
182 <Compile Include="Automaton\DFATable.cs" />
182 <Compile Include="Automaton\DFATable.cs" />
183 <Compile Include="Automaton\RegularExpressions\RegularExpressionVisitor.cs" />
183 <Compile Include="Automaton\RegularExpressions\RegularExpressionVisitor.cs" />
184 <Compile Include="Automaton\RegularExpressions\ITaggedDFABuilder.cs" />
184 <Compile Include="Automaton\RegularExpressions\ITaggedDFABuilder.cs" />
185 <Compile Include="Formats\TextScanner.cs" />
185 <Compile Include="Formats\TextScanner.cs" />
186 <Compile Include="Formats\StringScanner.cs" />
186 <Compile Include="Formats\StringScanner.cs" />
187 <Compile Include="Formats\ReaderScanner.cs" />
187 <Compile Include="Formats\ReaderScanner.cs" />
188 <Compile Include="Formats\ScannerContext.cs" />
188 <Compile Include="Formats\ScannerContext.cs" />
189 <Compile Include="Formats\Grammar.cs" />
189 <Compile Include="Formats\Grammar.cs" />
190 <Compile Include="Automaton\RegularExpressions\EndTokenT.cs" />
190 <Compile Include="Automaton\RegularExpressions\EndTokenT.cs" />
191 <Compile Include="Automaton\RegularExpressions\EndToken.cs" />
191 <Compile Include="Automaton\RegularExpressions\EndToken.cs" />
192 <Compile Include="Automaton\RegularExpressions\RegularExpressionVisitorT.cs" />
192 <Compile Include="Automaton\RegularExpressions\RegularExpressionVisitorT.cs" />
193 <Compile Include="Automaton\AutomatonConst.cs" />
193 <Compile Include="Automaton\AutomatonConst.cs" />
194 <Compile Include="Automaton\RegularExpressions\RegularDFA.cs" />
194 <Compile Include="Automaton\RegularExpressions\RegularDFA.cs" />
195 <Compile Include="Components\LazyAndWeak.cs" />
195 <Compile Include="Components\LazyAndWeak.cs" />
196 <Compile Include="AbstractTask.cs" />
197 <Compile Include="AbstractTaskT.cs" />
196 </ItemGroup>
198 </ItemGroup>
197 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
199 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
198 <ItemGroup />
200 <ItemGroup />
199 <ProjectExtensions>
201 <ProjectExtensions>
200 <MonoDevelop>
202 <MonoDevelop>
201 <Properties>
203 <Properties>
202 <Policies>
204 <Policies>
203 <CSharpFormattingPolicy IndentSwitchBody="True" NamespaceBraceStyle="EndOfLine" ClassBraceStyle="EndOfLine" InterfaceBraceStyle="EndOfLine" StructBraceStyle="EndOfLine" EnumBraceStyle="EndOfLine" MethodBraceStyle="EndOfLine" ConstructorBraceStyle="EndOfLine" DestructorBraceStyle="EndOfLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" NewLineBeforeConstructorInitializerColon="NewLine" NewLineAfterConstructorInitializerColon="SameLine" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
205 <CSharpFormattingPolicy IndentSwitchBody="True" NamespaceBraceStyle="EndOfLine" ClassBraceStyle="EndOfLine" InterfaceBraceStyle="EndOfLine" StructBraceStyle="EndOfLine" EnumBraceStyle="EndOfLine" MethodBraceStyle="EndOfLine" ConstructorBraceStyle="EndOfLine" DestructorBraceStyle="EndOfLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" NewLineBeforeConstructorInitializerColon="NewLine" NewLineAfterConstructorInitializerColon="SameLine" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
204 <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
206 <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
205 <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
207 <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
206 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" />
208 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" />
207 <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" />
209 <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" />
208 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
210 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
209 <NameConventionPolicy>
211 <NameConventionPolicy>
210 <Rules>
212 <Rules>
211 <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
213 <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
212 <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
214 <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
213 <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
215 <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
214 <RequiredPrefixes>
216 <RequiredPrefixes>
215 <String>I</String>
217 <String>I</String>
216 </RequiredPrefixes>
218 </RequiredPrefixes>
217 </NamingRule>
219 </NamingRule>
218 <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
220 <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
219 <RequiredSuffixes>
221 <RequiredSuffixes>
220 <String>Attribute</String>
222 <String>Attribute</String>
221 </RequiredSuffixes>
223 </RequiredSuffixes>
222 </NamingRule>
224 </NamingRule>
223 <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
225 <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
224 <RequiredSuffixes>
226 <RequiredSuffixes>
225 <String>EventArgs</String>
227 <String>EventArgs</String>
226 </RequiredSuffixes>
228 </RequiredSuffixes>
227 </NamingRule>
229 </NamingRule>
228 <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
230 <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
229 <RequiredSuffixes>
231 <RequiredSuffixes>
230 <String>Exception</String>
232 <String>Exception</String>
231 </RequiredSuffixes>
233 </RequiredSuffixes>
232 </NamingRule>
234 </NamingRule>
233 <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
235 <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
234 <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" />
236 <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" />
235 <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
237 <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
236 <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" />
238 <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" />
237 <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
239 <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
238 <RequiredPrefixes>
240 <RequiredPrefixes>
239 <String>m_</String>
241 <String>m_</String>
240 </RequiredPrefixes>
242 </RequiredPrefixes>
241 </NamingRule>
243 </NamingRule>
242 <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True">
244 <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True">
243 <RequiredPrefixes>
245 <RequiredPrefixes>
244 <String>_</String>
246 <String>_</String>
245 </RequiredPrefixes>
247 </RequiredPrefixes>
246 </NamingRule>
248 </NamingRule>
247 <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
249 <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
248 <RequiredPrefixes>
250 <RequiredPrefixes>
249 <String>m_</String>
251 <String>m_</String>
250 </RequiredPrefixes>
252 </RequiredPrefixes>
251 </NamingRule>
253 </NamingRule>
252 <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
254 <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
253 <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
255 <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
254 <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
256 <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
255 <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
257 <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
256 <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
258 <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
257 <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
259 <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
258 <RequiredPrefixes>
260 <RequiredPrefixes>
259 <String>T</String>
261 <String>T</String>
260 </RequiredPrefixes>
262 </RequiredPrefixes>
261 </NamingRule>
263 </NamingRule>
262 </Rules>
264 </Rules>
263 </NameConventionPolicy>
265 </NameConventionPolicy>
264 </Policies>
266 </Policies>
265 </Properties>
267 </Properties>
266 </MonoDevelop>
268 </MonoDevelop>
267 </ProjectExtensions>
269 </ProjectExtensions>
268 <ItemGroup>
270 <ItemGroup>
269 <Folder Include="Components\" />
271 <Folder Include="Components\" />
270 <Folder Include="Automaton\RegularExpressions\" />
272 <Folder Include="Automaton\RegularExpressions\" />
271 <Folder Include="Formats\" />
273 <Folder Include="Formats\" />
272 <Folder Include="Formats\JSON\" />
274 <Folder Include="Formats\JSON\" />
273 </ItemGroup>
275 </ItemGroup>
274 </Project> No newline at end of file
276 </Project>
General Comments 0
You need to be logged in to leave comments. Login now