public bool Equals(DestinyVendorCategoryOverlayDefinition input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     ChoiceDescription == input.ChoiceDescription ||
                     (ChoiceDescription != null && ChoiceDescription.Equals(input.ChoiceDescription))
                     ) &&
                 (
                     Description == input.Description ||
                     (Description != null && Description.Equals(input.Description))
                 ) &&
                 (
                     Icon == input.Icon ||
                     (Icon != null && Icon.Equals(input.Icon))
                 ) &&
                 (
                     Title == input.Title ||
                     (Title != null && Title.Equals(input.Title))
                 ) &&
                 (
                     CurrencyItemHash == input.CurrencyItemHash ||
                     (CurrencyItemHash.Equals(input.CurrencyItemHash))
                 ));
        }
Example #2
0
 public Choice(ChoiceDescription choiceDescription, int index, bool selected)
 {
     Label       = choiceDescription.Label.Replace("&", "");
     HelpMessage = choiceDescription.HelpMessage;
     Index       = index;
     Selected    = selected;
 }
Example #3
0
        protected override async Task EndProcessingAsync()
        {
            if (!hasException)
            {
                ChoiceDescription yes = new ChoiceDescription("&Yes", "(recommended) for relation integrity. The actual export directory will be deleted and recreated.");
                ChoiceDescription no  = new ChoiceDescription("&No", "Observer will be stopped permanenty.");

                System.Collections.ObjectModel.Collection <ChoiceDescription> choices = new System.Collections.ObjectModel.Collection <ChoiceDescription>()
                {
                    yes, no
                };
                string caption = "Observing object changes is stopped";
                string message = "Do you want to proceed an full sync?";
                int    result  = Host.UI.PromptForChoice(caption, message, choices, 0);

                if (result == 0)
                {
                    Host.UI.WriteLine("");
                    Host.UI.Write("Processing full synchronization");
                    await ProcessingFullSynchronization();

                    Host.UI.WriteLine("");
                    Host.UI.Write("Processing full synchronization finished.");
                }
            }
        }
 /// <summary>
 /// Creates a new instance of the ChoicePromptDetails class
 /// based on a ChoiceDescription from the PowerShell layer.
 /// </summary>
 /// <param name="choiceDescription">
 /// A ChoiceDescription on which this instance will be based.
 /// </param>
 /// <returns>A new ChoicePromptDetails instance.</returns>
 public static ChoiceDetails Create(ChoiceDescription choiceDescription)
 {
     return(new ChoiceDetails
     {
         Label = choiceDescription.Label,
         HelpMessage = choiceDescription.HelpMessage
     });
 }
        protected virtual void ProcessByUpdatedObject(object updatedObject, bool removeEmpty)
        {
            if (!this.MyInvocation.BoundParameters.ContainsKey("RemoveEmptyProperties"))
            {
                int UserChoice = 0;

                ChoiceDescription Yes = new ChoiceDescription("&Remove", "Will remove empty and null values from the object during serialization.");
                ChoiceDescription No  = new ChoiceDescription("&Keep", "Will keep empty and null values and overwrite any existing values.");
                Collection <ChoiceDescription> Choices = new Collection <ChoiceDescription>()
                {
                    Yes, No
                };
                UserChoice = Host.UI.PromptForChoice("Update Infoblox Object", ("Do you want to remove the empty properties when sending the object?"), Choices, 0);

                switch (UserChoice)
                {
                default:
                case 0:
                {
                    removeEmpty = true;
                    break;
                }

                case 1:
                {
                    removeEmpty = false;
                    break;
                }
                }
            }

            StringWriter SWriter     = new StringWriter();
            TextWriter   OriginalOut = Console.Out;

            Console.SetOut(SWriter);

            try
            {
                updatedObject.GetType().GetProperty("_ref").SetValue(updatedObject, this._Ref);
                this.Response = this.IBX.UpdateIbxObject(updatedObject, removeEmpty).Result;
            }
            catch (AggregateException ae)
            {
                PSCommon.WriteExceptions(ae, this.Host);
                this.ThrowTerminatingError(new ErrorRecord(ae.InnerException, ae.InnerException.GetType().FullName, ErrorCategory.NotSpecified, this));
            }
            catch (Exception e)
            {
                PSCommon.WriteExceptions(e, this.Host);
                this.ThrowTerminatingError(new ErrorRecord(e, e.GetType().FullName, ErrorCategory.NotSpecified, this));
            }
            finally
            {
                WriteVerbose(SWriter.ToString());
                Console.SetOut(OriginalOut);
            }
        }
Example #6
0
        public ChoiceItem(ChoiceDescription choiceDescription)
        {
            if (choiceDescription == null)
            {
                throw new ArgumentNullException("choiceDescription");
            }

            this.Label       = choiceDescription.Label.Replace('&', '_');
            this.HelpMessage = choiceDescription.HelpMessage;
        }
Example #7
0
    void Awake()
    {
        choice_description = GetComponentInChildren <ChoiceDescription>();
        choice_key         = GetComponentInChildren <ChoiceKey>();
        renderer           = GetComponent <SpriteRenderer>();
        platform           = Application.platform;
        collider           = GetComponent <Collider2D>();

        start_color = renderer.color;

        if (dev_placeholder)
        {
            print("Cleaning up placeholder grid object");
            DestroyImmediate(gameObject);
        }
    }
Example #8
0
 public virtual void ChoicePrompt(ChoiceDescription choice)
 {
 }
Example #9
0
 /// <summary>
 /// Creates a new instance of the ChoicePromptDetails class
 /// based on a ChoiceDescription from the PowerShell layer.
 /// </summary>
 /// <param name="choiceDescription">
 /// A ChoiceDescription on which this instance will be based.
 /// </param>
 /// <returns>A new ChoicePromptDetails instance.</returns>
 public static ChoiceDetails Create(ChoiceDescription choiceDescription)
 {
     return(new ChoiceDetails(
                choiceDescription.Label,
                choiceDescription.HelpMessage));
 }
        public override int PromptForChoice(string caption, string message, Collection <ChoiceDescription> choices, int defaultChoice)
        {
            if (!String.IsNullOrEmpty(caption))
            {
                WriteLine(caption);
            }

            if (!String.IsNullOrEmpty(message))
            {
                WriteLine(message);
            }

            int chosen = -1;

            do
            {
                // holds hotkeys, e.g. "[Y] Yes [N] No"
                var accelerators = new string[choices.Count];

                for (int index = 0; index < choices.Count; index++)
                {
                    ChoiceDescription choice = choices[index];
                    string            label  = choice.Label;
                    int ampIndex             = label.IndexOf('&'); // hotkey marker
                    accelerators[index] = String.Empty;            // default to empty

                    // accelerator marker found?
                    if (ampIndex != -1 &&
                        ampIndex < label.Length - 1)
                    {
                        // grab the letter after '&'
                        accelerators[index] = label
                                              .Substring(ampIndex + 1, 1)
                                              .ToUpper(CultureInfo.CurrentCulture);
                    }

                    Write(String.Format(CultureInfo.CurrentCulture, "[{0}] {1}  ",
                                        accelerators[index],
                                        // remove the redundant marker from output
                                        label.Replace("&", String.Empty)));
                }

                Write(String.Format(CultureInfo.CurrentCulture, Resources.PromptForChoiceSuffix, accelerators[defaultChoice]));

                string input = ReadLine().Trim();
                switch (input.Length)
                {
                case 0:
                    // enter, accept default if provided
                    if (defaultChoice == -1)
                    {
                        continue;
                    }
                    chosen = defaultChoice;
                    break;

                case 1:
                    if (input[0] == '?')
                    {
                        // show help
                        for (int index = 0; index < choices.Count; index++)
                        {
                            WriteLine(String.Format(
                                          CultureInfo.CurrentCulture, "{0} - {1}.", accelerators[index], choices[index].HelpMessage));
                        }
                    }
                    else
                    {
                        // single letter accelerator, e.g. "Y"
                        chosen = Array.FindIndex(
                            accelerators,
                            accelerator => accelerator.Equals(
                                input,
                                StringComparison.OrdinalIgnoreCase));
                    }
                    break;

                default:
                    // match against entire label, e.g. "Yes"
                    chosen = Array.FindIndex(
                        choices.ToArray(),
                        choice => choice.Label.Equals(
                            input,
                            StringComparison.OrdinalIgnoreCase));
                    break;
                }
            }while (chosen == -1);

            return(chosen);
        }