OSDN Git Service

AppliStation-All,アセンブリバージョンを1.4.3に
[applistation/AppliStation.git] / na-get-lib / NaGet.SubCommands.SubTask / FunctionalSubTask.cs
1 using System;
2 using System.Diagnostics;
3 using NaGet.Tasks;
4
5 namespace NaGet.SubCommands.SubTask
6 {
7         /// <summary>
8         /// 関数をサブタスク化
9         /// </summary>
10         public class FunctionalSubTask<T> : NaGetSubTask
11         {
12                 private Action<T> func = null;
13                 
14                 private T arg = default(T);
15                 
16                 /// <summary>
17                 /// コンストラクタ
18                 /// </summary>
19                 /// <param name="func">関数</param>
20                 /// <param name="arg">関数への引数</param>
21                 public FunctionalSubTask(Action<T> func, T arg)
22                 {
23                         this.func = func;
24                         this.arg = arg;
25                 }
26                 
27                 public override void Run()
28                 {
29                         NotifyStarted();
30                         try {
31                                 func(arg);
32                         } finally {
33                                 NotifyCompleted();
34                         }
35                 }
36                 
37                 /// <summary>
38                 /// 進捗は提供しない。
39                 /// </summary>
40                 public override bool UseProgress {
41                         get { return false; }
42                 }
43         }
44 }