PageRenderTime 34ms CodeModel.GetById 26ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Source/RemoveFIMResource.cs

#
C# | 40 lines | 35 code | 5 blank | 0 comment | 1 complexity | 67b8a073bfd61b78c88e3b43ab930822 MD5 | raw file
 1using System;
 2using System.Management.Automation;
 3using Microsoft.ResourceManagement.ObjectModel;
 4
 5namespace Quest.FIMPowerShellSnapin
 6{
 7    [Cmdlet(VerbsCommon.Remove, Constants.Nouns.FIMResource, SupportsShouldProcess = true)]
 8    public class RemoveFIMResource : PSCmdlet
 9    {
10        private String _objectID;
11        private FIMPSSession _session;
12
13        [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
14        [ValidateNotNullOrEmpty]
15        public String ObjectID
16        {
17            get { return _objectID; }
18            set { _objectID = value; }
19        }
20
21        [Parameter(Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
22        [ValidateNotNullOrEmpty]
23        public FIMPSSession Session
24        {
25            get { return _session; }
26            set { _session = value; }
27        }
28
29        protected override void ProcessRecord()
30        {
31            bool shouldProcess = ShouldProcess(Constants.Messages.VerboseRemove, Constants.Messages.ConfirmRemove, _objectID);
32
33            if (shouldProcess)
34            {
35                RmReference id = new RmReference(_objectID);
36                _session.Client.Delete(id); //!!! should we do anything with the return value?
37            }
38        }
39    }
40}