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