protected override void ProcessRecord()

in src/Public/Commands/PushOutputBindingCommand.cs [102:154]


        protected override void ProcessRecord()
        {
            if (!_outputBindings.ContainsKey(Name))
            {
                switch (_behavior)
                {
                    case DataCollectingBehavior.Singleton:
                        _outputBindings[Name] = Value;
                        return;

                    case DataCollectingBehavior.Collection:
                        var newValue = MergeCollection(oldData: null, newData: Value);
                        _outputBindings[Name] = newValue;
                        return;

                    default:
                        throw new InvalidOperationException(
                            string.Format(PowerShellWorkerStrings.UnrecognizedBehavior, _behavior.ToString()));
                }
            }

            // Key already exists in _outputBindings
            switch (_behavior)
            {
                case DataCollectingBehavior.Singleton:
                    if (Clobber.IsPresent)
                    {
                        _outputBindings[Name] = Value;
                    }
                    else
                    {
                        string errorMsg = string.Format(PowerShellWorkerStrings.OutputBindingAlreadySet, Name, _bindingInfo.Type);
                        ErrorRecord er = new ErrorRecord(
                            new InvalidOperationException(errorMsg),
                            nameof(PowerShellWorkerStrings.OutputBindingAlreadySet),
                            ErrorCategory.InvalidOperation,
                            targetObject: _bindingInfo.Type);

                        this.ThrowTerminatingError(er);
                    }
                    break;

                case DataCollectingBehavior.Collection:
                    object oldValue = Clobber.IsPresent ? null : _outputBindings[Name];
                    object newValue = MergeCollection(oldData: oldValue, newData: Value);
                    _outputBindings[Name] = newValue;
                    break;

                default:
                    throw new InvalidOperationException(
                        string.Format(PowerShellWorkerStrings.UnrecognizedBehavior, _behavior.ToString()));
            }
        }