Esempio n. 1
0
        private void Init(Type commandType, bool shouldGenerateCommonParameters)
        {
            this.type = commandType != null ? commandType : throw CommandMetadata.tracer.NewArgumentNullException("cmdletType");
            InternalParameterMetadata parameterMetadata = InternalParameterMetadata.Get(commandType, (ExecutionContext)null, false);

            this.ConstructCmdletMetadataUsingReflection();
            this.externalParameterMetadata = ParameterMetadata.GetParameterMetadata(this.MergeParameterMetadata((ExecutionContext)null, parameterMetadata, shouldGenerateCommonParameters));
            this.wrappedCommand            = this.commandName;
            this.wrappedCommandType        = CommandTypes.Cmdlet;
            this.wrappedAnyCmdlet          = true;
        }
Esempio n. 2
0
        private void Init(ScriptBlock scriptBlock, string name, bool shouldGenerateCommonParameters)
        {
            if (scriptBlock.UsesCmdletBinding)
            {
                this.wrappedAnyCmdlet = true;
            }
            else
            {
                shouldGenerateCommonParameters = false;
            }
            CmdletBindingAttribute bindingAttribute = scriptBlock.CmdletBindingAttribute;

            if (bindingAttribute != null)
            {
                this.ProcessCmdletAttribute((CmdletCommonMetadataAttribute)bindingAttribute);
            }
            else if (scriptBlock.UsesCmdletBinding)
            {
                this.defaultParameterSetName = (string)null;
            }
            this.externalParameterMetadata = ParameterMetadata.GetParameterMetadata(this.MergeParameterMetadata((ExecutionContext)null, InternalParameterMetadata.Get(scriptBlock.RuntimeDefinedParameters, false, scriptBlock.UsesCmdletBinding), shouldGenerateCommonParameters));
            this.wrappedCommand            = this.commandName = name;
        }