Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes308downloads
NativeCommandParameterBinderController.cs107 linesDownload Raw Back to engine
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System.Collections.ObjectModel;5 6namespace System.Management.Automation7{8    /// <summary>9    /// This is the interface between the NativeCommandProcessor and the10    /// parameter binders required to bind parameters to a native command.11    /// </summary>12    internal class NativeCommandParameterBinderController : ParameterBinderController13    {14        #region ctor15 16        /// <summary>17        /// Initializes the cmdlet parameter binder controller for18        /// the specified native command and engine context.19        /// </summary>20        /// <param name="command">21        /// The command that the parameters will be bound to.22        /// </param>23        internal NativeCommandParameterBinderController(NativeCommand command)24            : base(command.MyInvocation, command.Context, new NativeCommandParameterBinder(command))25        {26        }27 28        #endregion ctor29 30        /// <summary>31        /// Gets the command arguments in string form.32        /// </summary>33        internal string Arguments34        {35            get36            {37                return ((NativeCommandParameterBinder)DefaultParameterBinder).Arguments;38            }39        }40 41        /// <summary>42        /// Gets the value of the command arguments as an array of strings.43        /// </summary>44        internal string[] ArgumentList45        {46            get47            {48                return ((NativeCommandParameterBinder)DefaultParameterBinder).ArgumentList;49            }50        }51 52        /// <summary>53        /// Gets the value indicating what type of native argument binding to use.54        /// </summary>55        internal NativeArgumentPassingStyle ArgumentPassingStyle56        {57            get58            {59                return ((NativeCommandParameterBinder)DefaultParameterBinder).ArgumentPassingStyle;60            }61        }62 63        /// <summary>64        /// Passes the binding directly through to the parameter binder.65        /// It does no verification against metadata.66        /// </summary>67        /// <param name="argument">68        /// The name and value of the variable to bind.69        /// </param>70        /// <param name="flags">71        /// Ignored.72        /// </param>73        /// <returns>74        /// True if the parameter was successfully bound. Any error condition produces an exception.75        /// </returns>76        internal override bool BindParameter(77            CommandParameterInternal argument,78            ParameterBindingFlags flags)79        {80            Diagnostics.Assert(false, "Unreachable code");81 82            throw new InvalidOperationException();83        }84 85        /// <summary>86        /// Binds the specified parameters to the native command.87        /// </summary>88        /// <param name="parameters">89        /// The parameters to bind.90        /// </param>91        /// <remarks>92        /// For any parameters that do not have a name, they are added to the command93        /// line arguments for the command94        /// </remarks>95        internal override Collection<CommandParameterInternal> BindParameters(Collection<CommandParameterInternal> parameters)96        {97            ((NativeCommandParameterBinder)DefaultParameterBinder).BindParameters(parameters);98 99            Diagnostics.Assert(s_emptyReturnCollection.Count == 0, "This list shouldn't be used for anything as it's shared.");100 101            return s_emptyReturnCollection;102        }103 104        private static readonly Collection<CommandParameterInternal> s_emptyReturnCollection = new Collection<CommandParameterInternal>();105    }106}107