Esempio n. 1
0
        internal static string FormatCommandModel(CommandModel model, CommandFormatterOptions options)
        {
            if (model == null)
            {
                return(string.Empty);
            }

            var formatStyle  = options.FormateStyle;
            var parameterSet = options.ParameterSet;
            var sb           = new StringBuilder();

            switch (formatStyle)
            {
            case CommandFormatStyle.Inline:
                FormatCommandModelAsInlne(sb, model, parameterSet);
                break;

            case CommandFormatStyle.HashTable:
                FormatCommandModelAsHashTable(sb, model, parameterSet);
                break;

            default:
                FormatCommandModelAsInlne(sb, model, parameterSet);
                break;
            }

            return(sb.ToString());
        }
        private void UpdateCommandPreview()
        {
            try
            {
                CommandFormatterOptions options = new CommandFormatterOptions()
                {
                    FormateStyle = _options.FormatAsHashTable ? CommandFormatStyle.HashTable : CommandFormatStyle.Inline,
                    ParameterSet = _selectedItem
                };

                CommandPreview = CommandFormatter.FormatCommandModel(Model, options);
            }
            catch (Exception ex)
            {
                Log.Error("Exception while updating the command preview", ex);
            }
        }