Changeset 7633 for lang/powershell
- Timestamp:
- 03/07/08 21:57:00 (9 months ago)
- Location:
- lang/powershell/PSCustomProviders/trunk
- Files:
-
- 2 added
- 4 modified
-
analysys (added)
-
analysys/All.xml (added)
-
format/pstodo.format.ps1xml (modified) (2 diffs)
-
src/Dotnet.PowerShell.PSTodo.Test/PSTodo/PSTodoProvider_Test.cs (modified) (2 diffs)
-
src/Dotnet.PowerShell.PSTodo/PSTodo/PSTodoItem.cs (modified) (2 diffs)
-
src/Dotnet.PowerShell.PSTodo/PSTodo/PSTodoProvider.cs (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/powershell/PSCustomProviders/trunk/format/pstodo.format.ps1xml
r7623 r7633 44 44 </TableColumnHeader> 45 45 <TableColumnHeader> 46 <Label>期日</Label> 47 <Width>12</Width> 48 <Alignment>Right</Alignment> 49 </TableColumnHeader> 50 <TableColumnHeader> 46 51 <Label>詳細</Label> 47 52 </TableColumnHeader> … … 66 71 } 67 72 </ScriptBlock> 73 </TableColumnItem> 74 <TableColumnItem> 75 <PropertyName>Title</PropertyName> 68 76 </TableColumnItem> 69 77 <TableColumnItem> 70 <PropertyName>Title</PropertyName> 78 <ScriptBlock> 79 if($_.TimeLimit -ne [DateTime]::MinValue) { 80 $_.TimeLimit.ToString("yyyy/MM/dd"); 81 } else { 82 "なし" 83 } 84 </ScriptBlock> 71 85 </TableColumnItem> 72 86 <TableColumnItem> -
lang/powershell/PSCustomProviders/trunk/src/Dotnet.PowerShell.PSTodo.Test/PSTodo/PSTodoProvider_Test.cs
r7623 r7633 130 130 /// </summary> 131 131 [Test, Category("Success")] 132 public void アイテムを追加できる () {132 public void アイテムを追加できる_ケース1() { 133 133 CreateTodoDrive("case-1"); 134 134 135 Collection<PSObject> result = rsEngine.Invoke("New-Item Hoge -Description HogeHoge -Priority High ");135 Collection<PSObject> result = rsEngine.Invoke("New-Item Hoge -Description HogeHoge -Priority High -TimeLimit 2008/1/3"); 136 136 137 137 Assert.That(result, Has.Property("Count", 1)); … … 142 142 Assert.That(item.Description, Is.EqualTo("HogeHoge")); 143 143 Assert.That(item.Priority, Is.EqualTo(ItemPriority.High)); 144 Assert.That(item.TimeLimit, Is.EqualTo(DateTime.Parse("2008/1/3"))); 144 145 Assert.That(item.IsComplete, Is.False); 146 } 147 148 /// <summary> 149 /// アイテムを追加する。(パイプライン) 150 /// </summary> 151 [Test, Category("Success")] 152 public void アイテムを追加できる_ケース2() { 153 CreateTodoDrive("case-1"); 154 155 Collection<PSObject> result = rsEngine.Invoke("'Hello' | New-Item 200"); 156 157 // パイプラインのオブジェクトはDescriptionに渡される。 158 Assert.That(result[0].BaseObject, Has.Property("Description", "Hello")); 145 159 } 146 160 -
lang/powershell/PSCustomProviders/trunk/src/Dotnet.PowerShell.PSTodo/PSTodo/PSTodoItem.cs
r7623 r7633 46 46 private string description; 47 47 private ItemPriority priority = ItemPriority.Middle; 48 private DateTime timeLimit; 48 49 49 50 private bool isComplete; … … 75 76 get { return priority; } 76 77 set { priority = value; } 78 } 79 80 /// <summary> 81 /// 期日を取得、設定します。 82 /// </summary> 83 public DateTime TimeLimit { 84 get { return timeLimit; } 85 set { timeLimit = value; } 77 86 } 78 87 -
lang/powershell/PSCustomProviders/trunk/src/Dotnet.PowerShell.PSTodo/PSTodo/PSTodoProvider.cs
r7623 r7633 59 59 #region fields 60 60 61 private string title; 61 62 private string description; 62 63 private ItemPriority? priority; 64 private DateTime? timeLimit; 65 63 66 private SwitchParameter complete; 64 67 … … 68 71 69 72 /// <summary> 73 /// タイトルを取得、設定します。 74 /// </summary> 75 public string Title { 76 get { return title; } 77 set { title = value; } 78 } 79 80 /// <summary> 70 81 /// 詳細を取得、設定します。 71 82 /// </summary> 72 [Parameter(Position = 0)]83 [Parameter(Position=0, ValueFromPipeline=true)] 73 84 public string Description { 74 get { return description; } 85 get { 86 // 詳細が指定されていない場合は、タイトルを返すようにする。 87 return string.IsNullOrEmpty(description) ? title : description; 88 } 75 89 set { description = value; } 76 90 } … … 79 93 /// 優先度を取得、設定します。 80 94 /// </summary> 81 [Parameter(Position =1)]95 [Parameter(Position=1)] 82 96 public ItemPriority? Priority { 83 97 get { return priority; } … … 86 100 87 101 /// <summary> 102 /// 期日を取得、設定します。 103 /// </summary> 104 [Parameter(Position=2)] 105 public DateTime? TimeLimit { 106 get { return timeLimit; } 107 set { timeLimit = value; } 108 } 109 110 /// <summary> 88 111 /// 完了したかどうかを取得、設定します。 89 112 /// </summary> 90 [Parameter(Position = 2)]113 [Parameter(Position=3)] 91 114 public SwitchParameter Complete { 92 115 get { return complete; } … … 99 122 100 123 /// <summary> 101 /// 標準的なコンストラクタ 102 /// </summary> 103 public NewTodoItemParameters() { 124 /// タイトルを設定するコンストラクタ 125 /// </summary> 126 /// <param name="title">タイトル</param> 127 public NewTodoItemParameters(string title) { 128 #region ArgumentValidation 129 ArgumentValidation.CheckForNullOrEmpty(title, "title"); 130 #endregion 131 132 this.title = title; 104 133 } 105 134 … … 181 210 /// <param name="destPath">コピー先のパス</param> 182 211 /// <param name="itemParams">パラメータ</param> 183 /// <returns>更新したアイテム</returns> 184 private PSTodoItem CopyTodoItem(string path, string destPath, NewTodoItemParameters itemParams) { 212 private void CopyTodoItem(string path, string destPath, NewTodoItemParameters itemParams) { 185 213 PSTodoItem item = Deserialize(path); 186 item.Title = Path.GetFileName(destPath);187 214 // Move-Itemの時はnullなのよね 188 215 if(itemParams != null) { 189 if(!string.IsNullOrEmpty(itemParams.Description)) { 190 item.Description = itemParams.Description; 191 } 192 if(itemParams.Priority.HasValue) { 193 item.Priority = itemParams.Priority.Value; 194 } 216 item.Title = itemParams.Title; 195 217 item.IsComplete = itemParams.Complete; 218 if(itemParams.Priority.HasValue) item.Priority = itemParams.Priority.Value; 219 if(itemParams.TimeLimit.HasValue) item.TimeLimit = itemParams.TimeLimit.Value; 220 if(!string.IsNullOrEmpty(itemParams.Description)) item.Description = itemParams.Description; 221 222 } else { 223 item.Title = Path.GetFileName(destPath); 196 224 } 197 225 Serialize(item, destPath); 198 199 return item;200 226 } 201 227 … … 205 231 /// <param name="path">パス</param> 206 232 /// <param name="itemParams">パラメータ</param> 207 /// <returns>更新したアイテム</returns> 208 private PSTodoItem UpdateTodoItem(string path, NewTodoItemParameters itemParams) { 209 return CopyTodoItem(path, path, itemParams); 233 private void UpdateTodoItem(string path, NewTodoItemParameters itemParams) { 234 CopyTodoItem(path, path, itemParams); 210 235 } 211 236 … … 252 277 Path.GetFileName(path), itemParams.Description, itemParams.Complete 253 278 ); 254 if(itemParams.Priority.HasValue) {255 item.Priority = itemParams.Priority.Value;256 } 279 if(itemParams.Priority.HasValue) item.Priority = itemParams.Priority.Value; 280 if(itemParams.TimeLimit.HasValue) item.TimeLimit = itemParams.TimeLimit.Value; 281 257 282 Serialize(item, path); 258 283 … … 268 293 /// <param name="newItemValue"></param> 269 294 /// <returns></returns> 270 protected override object NewItemDynamicParameters(string path, string itemTypeName, object newItemValue) { return new NewTodoItemParameters(); } 295 protected override object NewItemDynamicParameters(string path, string itemTypeName, object newItemValue) { 296 return new NewTodoItemParameters(Path.GetFileName(path)); 297 } 271 298 272 299 /// <summary> … … 317 344 /// <param name="value"></param> 318 345 /// <returns></returns> 319 protected override object SetItemDynamicParameters(string path, object value) { return new NewTodoItemParameters(); } 346 protected override object SetItemDynamicParameters(string path, object value) { 347 return new NewTodoItemParameters(Path.GetFileName(path)); 348 } 320 349 321 350 /// <summary> … … 358 387 /// <param name="recurse"></param> 359 388 /// <returns></returns> 360 protected override object CopyItemDynamicParameters(string path, string destination, bool recurse) { return new NewTodoItemParameters(); } 389 protected override object CopyItemDynamicParameters(string path, string destination, bool recurse) { 390 return new NewTodoItemParameters(Path.GetFileName(destination)); 391 } 361 392 362 393 /// <summary>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)