/Source/Trunk/PSStudio/AspenManagementCmdlets/AspenManagementCmdlets/SetCmdletCommand.cs
# · C# · 511 lines · 465 code · 44 blank · 2 comment · 34 complexity · d462edddbd26cd62e048c47d121490d0 MD5 · raw file
- using System;
- using System.Collections.Generic;
- using System.Text;
-
- using System.Management.Automation;
-
- namespace Microsoft.PowerShell.CmdletManagement
- {
- [Cmdlet(VerbsCommon.Set, "PsSpecCmdlet", SupportsShouldProcess = true)]
- public class SetPsSpecCmdletCommand : PsSpecCommandBase
- {
- [Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true)]
- public int Id
- {
- get
- {
- return _id;
- }
- set
- {
- _id = value;
- }
- }
- private int _id = -1;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- public String Snapin
- {
- get
- {
- return _snapin;
- }
- set
- {
- if ((value != null) && (value.Length > 200))
- throw new ArgumentOutOfRangeException("Snapin");
-
- _snapin = value;
- }
- }
- private string _snapin;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [ValidateLength(1, 50)]
- public String Verb
- {
- get
- {
- return _verb;
- }
- set
- {
- _verb = value;
- }
- }
- private string _verb;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [ValidateLength(1, 50)]
- public String Noun
- {
- get
- {
- return _noun;
- }
- set
- {
- _noun = value;
- }
- }
- private string _noun;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String TeamMembers
- {
- get
- {
- return _teamMembers;
- }
- set
- {
- if ((value != null) && (value.Length > 500))
- throw new ArgumentOutOfRangeException("TeamMembers");
-
- _teamMembers = value;
- }
- }
- private string _teamMembers;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String ShortDescription
- {
- get
- {
- return _shortDescription;
- }
- set
- {
- if ((value != null) && (value.Length > 2000))
- throw new ArgumentOutOfRangeException("ShortDescription");
-
- _shortDescription = value;
- }
- }
- private string _shortDescription;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String LongDescription
- {
- get
- {
- return _longDescription;
- }
- set
- {
- _longDescription = value;
- }
- }
- private string _longDescription;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- public bool? SupportsShouldProcess
- {
- get
- {
- return _supportsShouldProcess;
- }
- set
- {
- _supportsShouldProcess = value;
- }
- }
- private bool? _supportsShouldProcess;
-
- [AllowNull]
- [AllowEmptyString]
- [Parameter(ValueFromPipelineByPropertyName = true)]
- public String Notes
- {
- get
- {
- return _notes;
- }
- set
- {
- _notes = value;
- }
- }
- private string _notes;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String SpecExamples
- {
- get
- {
- return _specExamples;
- }
- set
- {
- _specExamples = value;
- }
- }
- private string _specExamples;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- public PsSpecHelpExample[] HelpExamples
- {
- get
- {
- return _helpExamples;
- }
- set
- {
- _helpExamples = value;
- }
- }
- private PsSpecHelpExample[] _helpExamples;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String OutputObject
- {
- get
- {
- return _outputObject;
- }
- set
- {
- if ((value != null) && (value.Length > 500))
- throw new ArgumentOutOfRangeException("OutputObject");
-
- _outputObject = value;
- }
- }
- private string _outputObject;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String OutputObjectDescription
- {
- get
- {
- return _outputObjectDescription;
- }
- set
- {
- _outputObjectDescription = value;
- }
- }
- private string _outputObjectDescription;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String RelatedTo
- {
- get
- {
- return _relatedTo;
- }
- set
- {
- if ((value != null) && (value.Length > 1000))
- throw new ArgumentOutOfRangeException("RelatedTo");
-
- _relatedTo = value;
- }
- }
- private string _relatedTo;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String DefaultParameterSetName
- {
- get
- {
- return _defaultParameterSetName;
- }
- set
- {
- if ((value != null) && (value.Length > 50))
- throw new ArgumentOutOfRangeException("DefaultParameterSetName");
-
- _defaultParameterSetName = value;
- }
- }
- private string _defaultParameterSetName;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String Custom1
- {
- get
- {
- return _custom1;
- }
- set
- {
- _custom1 = value;
- }
- }
- private string _custom1;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String Custom2
- {
- get
- {
- return _custom2;
- }
- set
- {
- _custom2 = value;
- }
- }
- private string _custom2;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String Custom3
- {
- get
- {
- return _custom3;
- }
- set
- {
- _custom3 = value;
- }
- }
- private string _custom3;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String Custom4
- {
- get
- {
- return _custom4;
- }
- set
- {
- _custom4 = value;
- }
- }
- private string _custom4;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String Status
- {
- get
- {
- return _status;
- }
- set
- {
- if ((value != null) && (value.Length > 100))
- throw new ArgumentOutOfRangeException("Status");
-
- _status = value;
- }
- }
- private string _status;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String HelpStatus
- {
- get
- {
- return _helpStatus;
- }
- set
- {
- if ((value != null) && (value.Length > 100))
- throw new ArgumentOutOfRangeException("HelpStatus");
-
- _helpStatus = value;
- }
- }
- private string _helpStatus;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String HelpShortDescription
- {
- get
- {
- return _helpShortDescription;
- }
- set
- {
- if ((value != null) && (value.Length > 2000))
- throw new ArgumentOutOfRangeException("HelpShortDescription");
-
- _helpShortDescription = value;
- }
- }
- private string _helpShortDescription;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String HelpLongDescription
- {
- get
- {
- return _helpLongDescription;
- }
- set
- {
- _helpLongDescription = value;
- }
- }
- private string _helpLongDescription;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String InputObject
- {
- get
- {
- return _helpInputObject;
- }
- set
- {
- if ((value != null) && (value.Length > 500))
- throw new ArgumentOutOfRangeException("InputObject");
-
- _helpInputObject = value;
- }
- }
- private string _helpInputObject;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String HelpInputObjectDescription
- {
- get
- {
- return _helpInputObjectDescription;
- }
- set
- {
- _helpInputObjectDescription = value;
- }
- }
- private string _helpInputObjectDescription;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String HelpOutputObjectDescription
- {
- get
- {
- return _helpOutputObjectDescription;
- }
- set
- {
- _helpOutputObjectDescription = value;
- }
- }
- private string _helpOutputObjectDescription;
-
- [Parameter(ValueFromPipelineByPropertyName = true)]
- [AllowNull]
- [AllowEmptyString]
- public String HelpAdditionalNotes
- {
- get
- {
- return _helpAdditionalNotes;
- }
- set
- {
- _helpAdditionalNotes = value;
- }
- }
- private string _helpAdditionalNotes;
-
- protected override void ProcessRecord()
- {
- if (ShouldProcess(
- String.Format("{0}", ServiceUri),
- String.Format(resources.UpdateCmdletShouldProcess, Id)))
- {
- // Update the cmdlet
- try
- {
- PsSpecCmdletService.PsSpecHelpExample[] outgoingHelpExamples =
- new PsSpecCmdletService.PsSpecHelpExample[0];
-
- // Populate the help examples
- if (HelpExamples != null)
- {
- outgoingHelpExamples =
- new PsSpecCmdletService.PsSpecHelpExample[HelpExamples.Length];
-
- for (int counter = 0; counter < HelpExamples.Length; counter++)
- {
- PsSpecCmdletService.PsSpecHelpExample newExample =
- new PsSpecCmdletService.PsSpecHelpExample();
- PsSpecHelpExample incomingExample = HelpExamples[counter];
-
- newExample.Id = incomingExample.Id;
- newExample.Command = incomingExample.Command;
- newExample.Output = incomingExample.Output;
- newExample.Description = incomingExample.Description;
-
- outgoingHelpExamples[counter] = newExample;
- }
- }
-
- Service.UpdateCmdlet(Id, Snapin, Verb, Noun, TeamMembers, ShortDescription,
- HelpShortDescription, LongDescription, HelpLongDescription,
- Status, HelpStatus, SupportsShouldProcess, Notes, SpecExamples, outgoingHelpExamples,
- InputObject, HelpInputObjectDescription, OutputObject, OutputObjectDescription,
- HelpOutputObjectDescription, DefaultParameterSetName,
- RelatedTo, Custom1, Custom2, Custom3, Custom4, HelpAdditionalNotes, "%");
- }
- catch (System.Web.Services.Protocols.SoapException e)
- {
- WriteError(new ErrorRecord(e, "PROJECT_SERVICE_ERROR", ErrorCategory.InvalidOperation, Id));
- }
- }
- }
- }
- }