示例#1
0
        /// <summary>
        /// Creates the object. If it's syntax highlighted, it's a <see cref="TextBlock"/>, else
        /// it's just a <see cref="string"/>. See also <see cref="CreateTextBlock()"/>
        /// </summary>
        /// <returns></returns>
        public object CreateObject()
        {
            if (simpleHighlighter != null)
            {
                return(simpleHighlighter.Create());
            }

            return(output.ToString());
        }
示例#2
0
        /// <summary>
        /// Creates the object. If it's syntax highlighted, it's a <see cref="TextBlock"/>, else
        /// it's just a <see cref="string"/>. See also <see cref="CreateTextBlock()"/>
        /// </summary>
        /// <param name="useEllipsis">true to add <see cref="TextTrimming.CharacterEllipsis"/> to the <see cref="TextBlock"/></param>
        /// <param name="filterOutNewLines">true to filter out newline characters</param>
        /// <returns></returns>
        public object CreateObject(bool useEllipsis = false, bool filterOutNewLines = true)
        {
            if (simpleHighlighter != null)
            {
                return(simpleHighlighter.Create(useEllipsis, filterOutNewLines));
            }

            return(ToString(output.ToString(), filterOutNewLines));
        }
示例#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 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());
        }