Пример #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try {
                var flags = WriteObjectFlags.None;
                if (parameter != null)
                {
                    foreach (var c in (string)parameter)
                    {
                        if (c == 's')
                        {
                            flags |= WriteObjectFlags.ShortInstruction;
                        }
                    }
                }

                var gen = ColorizedTextElementProvider.Create(true);
                BodyUtils.WriteObject(gen.Output, value, flags);
                return(gen.CreateResult(true, true));
            }
            catch (Exception ex) {
                Debug.Fail(ex.ToString());
            }

            if (value == null)
            {
                return(string.Empty);
            }
            return(value.ToString());
        }
Пример #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try {
                var flags = WriteObjectFlags.None;
                if (parameter != null)
                {
                    foreach (var c in (string)parameter)
                    {
                        if (c == 's')
                        {
                            flags |= WriteObjectFlags.ShortInstruction;
                        }
                    }
                }

                var gen = new SimpleHighlighter();
                BodyUtils.WriteObject(gen.TextOutput, value, flags);
                var tb = gen.Create();
                tb.TextTrimming = TextTrimming.CharacterEllipsis;
                return(tb);
            }
            catch (Exception ex) {
                Debug.Fail(ex.ToString());
            }

            if (value == null)
            {
                return(string.Empty);
            }
            return(value.ToString());
        }
Пример #3
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try {
                var flags = WriteObjectFlags.None;
                if (parameter != null)
                {
                    foreach (var c in (string)parameter)
                    {
                        if (c == 's')
                        {
                            flags |= WriteObjectFlags.ShortInstruction;
                        }
                    }
                }

                var writer = Cache.GetWriter();
                try {
                    BodyUtils.WriteObject(writer, value, flags);
                    const bool colorize = true;
                    var        context  = new TextClassifierContext(writer.Text, PredefinedTextClassifierTags.MethodBodyEditor, colorize, writer.Colors);
                    var        elem     = textElementProvider.CreateTextElement(classificationFormatMap, context, ContentTypes.MethodBodyEditor, TextElementFlags.CharacterEllipsis | TextElementFlags.FilterOutNewLines);
                    Cache.FreeWriter(writer);
                    return(elem);
                }
                finally {
                    Cache.FreeWriter(writer);
                }
            }
            catch (Exception ex) {
                Debug.Fail(ex.ToString());
            }

            if (value == null)
            {
                return(string.Empty);
            }
            return(value.ToString());
        }