Esempio n. 1
0
        private void SetCurrentInputValues(IInputCollection inputs)
        {
            foreach (KeyValuePair <string, IRuntimeValue> input in inputs)
            {
                switch (input.Key)
                {
                case ("Module Name"):
                    _moduleName = input.Value.ToString();
                    break;

                case ("Cmdlet Name"):
                    _cmdletName = input.Value.ToString();
                    break;

                case ("ParameterSet"):
                    _parameterSetName = input.Value.ToString();
                    break;

                default:
                    //should not be here!
                    break;
                }
            }
        }
Esempio n. 2
0
        private async void OnStart()
        {
            output.WriteSplash();
            while (true)
            {
                historyProvider.Reset();
                output.WriteScopeBegin(hostEnv);
                string command = hostInput.ReadCommandLine();
                if (command == null)
                {
                    break;
                }
                IInputCollection inputCollection = Input.Internal.Input.Parse(command);
                if (inputCollection.ContainsError)
                {
                    output.WriteError(inputCollection.ErrorMessage);
                }
                else
                {
                    foreach (var desc in pool.GetDescriptors())
                    {
                        desc.EnterScope();
                    }

                    object      inputObject       = null;
                    int         index             = 0;
                    int         changeIndex       = inputCollection.Inputs.Count - 1;
                    bool        isInPipe          = inputCollection.Inputs.Count > 1;
                    bool        writeDefaultValue = !isInPipe;
                    HostContext context           = null;
                    foreach (IInput input in inputCollection.Inputs)
                    {
                        context = new HostContext(input, inputObject, isInPipe, index, writeDefaultValue);
                        AppDelegate app = appBuilder.Build();
                        await app(context);

                        if (context.ErrorOccured)
                        {
                            output.WriteError(context.Exception);
                            break;
                        }

                        if (context.WriteResult)
                        {
                            output.WriteObject(context.Result);
                        }
                        inputObject = context.Result;
                        if (inputObject != null)
                        {
                            inputObject = ObjectHelper.TryGetValue(inputObject);
                        }
                        index++;
                        if (index >= changeIndex)
                        {
                            writeDefaultValue = true;
                        }
                    }

                    foreach (var desc in pool.GetDescriptors())
                    {
                        desc.LeaveScope();
                    }
                }
                historyProvider.Add(inputCollection.Raw);
            }
        }
        ///############################################################
        /// <summary>
        /// Renders the control to the specified HTML writer.
        /// </summary>
        /// <remarks>
        /// NOTE: This function will ignore any non-existant <c>sInputAlias</c>'s.
        /// </remarks>
        /// <param name="sInputAlias">String representing the HTML input's unique base name.</param>
        /// <param name="eInputType">Enumeration representing the input type to render.</param>
        /// <param name="sInitialValue">String representing the initial value of the input.</param>
        /// <param name="a_sInitialValues">Array of strings where each element represents an initial value of the input.</param>
        /// <param name="bForceInitialValue">Boolean value representing if the value of the input is always to be set to <paramref name="sInitialValue"/>/<paramref name="a_sInitialValues"/>.</param>
        /// <param name="sAttributes">String representing the additional HTML attributes to apply to the input.</param>
        /// <param name="writer">HtmlTextWriter object as automatically provided by the host ASPX page.</param>
        /// <returns>Boolean value indicating if it is necessary to raise the <c>GenerateHTML</c> event.</returns>
        ///############################################################
        /// <LastUpdated>June 22, 2010</LastUpdated>
        public static bool DoRenderInput(string sInputAlias, enumInputTypes eInputType, string sInitialValue, string[] a_sInitialValues, bool bForceInitialValue, string sAttributes, HtmlTextWriter writer, IInputCollection oInputCollection)
        {
            bool bReturn = false;

            //	//#### If the passed sInputAlias .Exists
            //if (oInputCollection.Exists(sInputAlias)) {
            //#### If this is a non-.cnCustom control
            if (eInputType != enumInputTypes.cnCustom)
            {
                //#### Flip our bReturn value to true
                bReturn = true;

                //#### If the sInputAlias .IsMultiValue, call the a_sInitialValues version of .GenerateHTML
                if (oInputCollection.Inputs(sInputAlias).IsMultiValue)
                {
                    writer.Write(oInputCollection.GenerateHTML(sInputAlias, eInputType, a_sInitialValues, bForceInitialValue, sAttributes));
                }
                //#### Else the sInputAlias .Is(not a)MultiValue, so call the sInitialValue version of .GenerateHTML
                else
                {
                    writer.Write(oInputCollection.GenerateHTML(sInputAlias, eInputType, sInitialValue, bForceInitialValue, sAttributes));
                }
            }
            //}

            //#### Return the above determined bReturn value to the caller
            return(bReturn);
        }