OSDN Git Service

na-get-lib,新構造タスクのキャンセル処理を修正。
[applistation/AppliStation.git] / na-get-lib / NaGet.SubCommands.SubTask / NaGetSubTask.cs
1 using System;
2 using NaGet.Tasks;
3
4 namespace NaGet.SubCommands.SubTask
5 {
6         /// <summary>
7         /// サブタスクの基底クラス。
8         /// </summary>
9         public abstract class NaGetSubTask : Task
10         {
11                 private bool isRunning = false;
12                 
13                 private bool isDone = false;
14                 
15                 private bool isCancelled = false;
16                 
17                 public NaGetSubTask()
18                 {
19                 }
20                 
21                 /// <summary>
22                 /// 進捗情報を提供するか?
23                 /// </summary>
24                 public virtual bool UseProgress {
25                         get {
26                                 return true;
27                         }
28                 }
29                 
30                 public override bool Running {
31                         get {
32                                 return isRunning;
33                         }
34                 }
35                 
36                 public override bool Done {
37                         get {
38                                 return isDone;
39                         }
40                 }
41                 
42                 public virtual bool Cancelled {
43                         get {
44                                 return isCancelled;
45                         }
46                 }
47                 
48                 #region フラグ処理の便利メソッド
49                 
50                 /// <summary>
51                 /// 開始時に関するフラグの処理を行う
52                 /// </summary>
53                 protected virtual void NotifyStarted()
54                 {
55                         isRunning = true;
56                         isDone = false;
57                 }
58                 
59                 /// <summary>
60                 /// キャンセル中断時に関するフラグの処理を行う
61                 /// </summary>
62                 protected virtual void NotifyCancelled()
63                 {
64                         isRunning = false;
65                         isCancelled = true;
66                         isDone = true;
67                 }
68                 
69                 /// <summary>
70                 /// 成功終了時に関するフラグの処理を行う
71                 /// </summary>
72                 protected virtual void NotifyCompleted()
73                 {
74                         isRunning = false;
75                         isDone = true;
76                 }
77                 
78                 #endregion
79         }
80 }