Changeset 7633 for lang/powershell

Show
Ignore:
Timestamp:
03/07/08 21:57:00 (9 months ago)
Author:
coma2n
Message:

lang/powershell/PSCustomProviders/trunk: #79 の機能を実装した、NDependプロジェクトを追加

Location:
lang/powershell/PSCustomProviders/trunk
Files:
2 added
4 modified

Legend:

Unmodified
Added
Removed
  • lang/powershell/PSCustomProviders/trunk/format/pstodo.format.ps1xml

    r7623 r7633  
    4444                    </TableColumnHeader> 
    4545                    <TableColumnHeader> 
     46                        <Label>期日</Label> 
     47                        <Width>12</Width> 
     48                        <Alignment>Right</Alignment> 
     49                    </TableColumnHeader> 
     50                    <TableColumnHeader> 
    4651                        <Label>詳細</Label> 
    4752                    </TableColumnHeader> 
     
    6671                                } 
    6772                                </ScriptBlock> 
     73                            </TableColumnItem>                             
     74                            <TableColumnItem> 
     75                                <PropertyName>Title</PropertyName> 
    6876                            </TableColumnItem> 
    6977                            <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> 
    7185                            </TableColumnItem> 
    7286                            <TableColumnItem> 
  • lang/powershell/PSCustomProviders/trunk/src/Dotnet.PowerShell.PSTodo.Test/PSTodo/PSTodoProvider_Test.cs

    r7623 r7633  
    130130                /// </summary> 
    131131                [Test, Category("Success")] 
    132                 public void アイテムを追加できる() { 
     132                public void アイテムを追加できる_ケース1() { 
    133133                        CreateTodoDrive("case-1"); 
    134134 
    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"); 
    136136 
    137137                        Assert.That(result, Has.Property("Count", 1)); 
     
    142142                        Assert.That(item.Description, Is.EqualTo("HogeHoge")); 
    143143                        Assert.That(item.Priority, Is.EqualTo(ItemPriority.High)); 
     144                        Assert.That(item.TimeLimit, Is.EqualTo(DateTime.Parse("2008/1/3"))); 
    144145                        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")); 
    145159                } 
    146160 
  • lang/powershell/PSCustomProviders/trunk/src/Dotnet.PowerShell.PSTodo/PSTodo/PSTodoItem.cs

    r7623 r7633  
    4646                private string description; 
    4747                private ItemPriority priority = ItemPriority.Middle; 
     48                private DateTime timeLimit; 
    4849 
    4950                private bool isComplete; 
     
    7576                        get { return priority; } 
    7677                        set { priority = value; } 
     78                } 
     79 
     80                /// <summary> 
     81                /// 期日を取得、設定します。 
     82                /// </summary> 
     83                public DateTime TimeLimit { 
     84                        get { return timeLimit; } 
     85                        set { timeLimit = value; } 
    7786                } 
    7887 
  • lang/powershell/PSCustomProviders/trunk/src/Dotnet.PowerShell.PSTodo/PSTodo/PSTodoProvider.cs

    r7623 r7633  
    5959                        #region fields 
    6060 
     61                        private string title; 
    6162                        private string description; 
    6263                        private ItemPriority? priority; 
     64                        private DateTime? timeLimit; 
     65 
    6366                        private SwitchParameter complete; 
    6467 
     
    6871 
    6972                        /// <summary> 
     73                        /// タイトルを取得、設定します。 
     74                        /// </summary> 
     75                        public string Title { 
     76                                get { return title; } 
     77                                set { title = value; } 
     78                        } 
     79 
     80                        /// <summary> 
    7081                        /// 詳細を取得、設定します。 
    7182                        /// </summary> 
    72                         [Parameter(Position = 0)] 
     83                        [Parameter(Position=0, ValueFromPipeline=true)] 
    7384                        public string Description { 
    74                                 get { return description; } 
     85                                get { 
     86                                        // 詳細が指定されていない場合は、タイトルを返すようにする。 
     87                                        return string.IsNullOrEmpty(description) ? title : description; 
     88                                } 
    7589                                set { description = value; } 
    7690                        } 
     
    7993                        /// 優先度を取得、設定します。 
    8094                        /// </summary> 
    81                         [Parameter(Position = 1)] 
     95                        [Parameter(Position=1)] 
    8296                        public ItemPriority? Priority { 
    8397                                get { return priority; } 
     
    86100 
    87101                        /// <summary> 
     102                        /// 期日を取得、設定します。 
     103                        /// </summary> 
     104                        [Parameter(Position=2)] 
     105                        public DateTime? TimeLimit { 
     106                                get { return timeLimit; } 
     107                                set { timeLimit = value; } 
     108                        } 
     109 
     110                        /// <summary> 
    88111                        /// 完了したかどうかを取得、設定します。 
    89112                        /// </summary> 
    90                         [Parameter(Position = 2)] 
     113                        [Parameter(Position=3)] 
    91114                        public SwitchParameter Complete { 
    92115                                get { return complete; } 
     
    99122 
    100123                        /// <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; 
    104133                        } 
    105134 
     
    181210                /// <param name="destPath">コピー先のパス</param> 
    182211                /// <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) { 
    185213                        PSTodoItem item = Deserialize(path); 
    186                         item.Title = Path.GetFileName(destPath); 
    187214                        // Move-Itemの時はnullなのよね 
    188215                        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; 
    195217                                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); 
    196224                        } 
    197225                        Serialize(item, destPath); 
    198  
    199                         return item; 
    200226                } 
    201227 
     
    205231                /// <param name="path">パス</param> 
    206232                /// <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); 
    210235                } 
    211236 
     
    252277                                Path.GetFileName(path), itemParams.Description, itemParams.Complete 
    253278                        ); 
    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 
    257282                        Serialize(item, path); 
    258283 
     
    268293                /// <param name="newItemValue"></param> 
    269294                /// <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                } 
    271298 
    272299                /// <summary> 
     
    317344                /// <param name="value"></param> 
    318345                /// <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                } 
    320349 
    321350                /// <summary> 
     
    358387                /// <param name="recurse"></param> 
    359388                /// <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                } 
    361392 
    362393                /// <summary>