Esempio n. 1
0
        /// <summary>
        /// This is a copy constructor, used primarily for get-command.
        /// </summary>
        internal FunctionInfo(string name, FunctionInfo other)
            : base(name, other)
        {
            CopyFieldsFromOther(other);

            // Get the verb and noun from the name
            CmdletInfo.SplitCmdletName(name, out _verb, out _noun);
        }
Esempio n. 2
0
 internal FunctionInfo(string name, FunctionInfo other) : base(name, other)
 {
     this.verb      = string.Empty;
     this.noun      = string.Empty;
     this._helpFile = string.Empty;
     this.CopyFieldsFromOther(other);
     CmdletInfo.SplitCmdletName(name, out this.verb, out this.noun);
 }
Esempio n. 3
0
        /// <summary>
        /// Creates an instance of the FunctionInfo class with the specified name and ScriptBlock.
        /// </summary>
        /// <param name="name">
        /// The name of the function.
        /// </param>
        /// <param name="function">
        /// The ScriptBlock for the function
        /// </param>
        /// <param name="context">
        /// The execution context for the function.
        /// </param>
        /// <param name="helpFile">
        /// The name of the help file associated with the function.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="function"/> is null.
        /// </exception>
        internal FunctionInfo(string name, ScriptBlock function, ExecutionContext context, string helpFile) : base(name, CommandTypes.Function, context)
        {
            if (function == null)
            {
                throw PSTraceSource.NewArgumentNullException("function");
            }

            _scriptBlock = function;

            CmdletInfo.SplitCmdletName(name, out _verb, out _noun);

            this.Module = function.Module;
            _helpFile   = helpFile;
        }
Esempio n. 4
0
 internal FunctionInfo(string name, System.Management.Automation.ScriptBlock function, System.Management.Automation.ExecutionContext context, string helpFile) : base(name, CommandTypes.Function, context)
 {
     this.verb      = string.Empty;
     this.noun      = string.Empty;
     this._helpFile = string.Empty;
     if (function == null)
     {
         throw PSTraceSource.NewArgumentNullException("function");
     }
     this._scriptBlock = function;
     CmdletInfo.SplitCmdletName(name, out this.verb, out this.noun);
     base.SetModule(function.Module);
     this._helpFile = helpFile;
 }
Esempio n. 5
0
 internal CmdletInfo(
     string name,
     Type implementingType,
     string helpFile,
     PSSnapInInfo PSSnapin,
     ExecutionContext context)
     : base(name, CommandTypes.Cmdlet, context)
 {
     if (string.IsNullOrEmpty(name))
     {
         throw CmdletInfo.tracer.NewArgumentException(nameof(name));
     }
     if (implementingType == null)
     {
         throw CmdletInfo.tracer.NewArgumentNullException(nameof(implementingType));
     }
     if (!CmdletInfo.SplitCmdletName(name, out this.verb, out this.noun))
     {
         throw CmdletInfo.tracer.NewArgumentException(nameof(name), "DiscoveryExceptions", "InvalidCmdletNameFormat", (object)name);
     }
     this.implementingType = implementingType;
     this.helpFilePath     = helpFile;
     this._PSSnapin        = PSSnapin;
 }