コード例 #1
0
        /// <summary>
        /// Implements the begin action of the command
        /// </summary>
        protected override void BeginProcessing()
        {
            object outBuffer;

            if (MyInvocation.BoundParameters.TryGetValue("OutBuffer", out outBuffer))
            {
                MyInvocation.BoundParameters["OutBuffer"] = 1;
            }

            Hashtable clonedBoundParameters = new Hashtable();

            foreach (string key in MyInvocation.BoundParameters.Keys)
            {
                if (!_NonclonedProperties.Contains(key))
                {
                    clonedBoundParameters[key] = MyInvocation.BoundParameters[key];
                }
            }

            if (MyInvocation.BoundParameters.ContainsKey("Property"))
            {
                clonedBoundParameters["Property"] = Property.Select(o => o.Value).AsEnumerable().ToArray();
            }

            if ((ShowExcludeProperty.Length > 0) || (ShowProperty.Length > 0) || (!String.IsNullOrEmpty(TypeName)) || (KeepInputObject.ToBool()))
            {
                _NoAdjustment = false;
            }

            if (ShowProperty.Length > 0)
            {
                _DisplayPropertySet = new PSMemberInfo[] { new PSPropertySet("DefaultDisplayPropertySet", ShowProperty) }
            }
            ;

            // Set the list of parameters to a variable in the caller scope, so it can be splatted
            this.SessionState.PSVariable.Set("__PSFramework_SelectParam", clonedBoundParameters);
            ScriptBlock scriptCommand = ScriptBlock.Create("Select-Object @__PSFramework_SelectParam");

            _Pipeline = scriptCommand.GetSteppablePipeline(MyInvocation.CommandOrigin);

            if (_NoAdjustment)
            {
                _Pipeline.Begin(this);
            }
            else
            {
                _Pipeline.Begin(true);
            }
        }