Пример #1
0
        protected override int VisitSequenceValue(ThemedValueFormatterState state, SequenceValue sequence)
        {
            if (sequence == null)
            {
                throw new ArgumentNullException(nameof(sequence));
            }

            using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                state.Output.Write('[');

            var delim = string.Empty;

            for (var index = 0; index < sequence.Elements.Count; ++index)
            {
                if (delim.Length != 0)
                {
                    using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                        state.Output.Write(delim);
                }

                delim = ", ";
                Visit(state.Nest(), sequence.Elements[index]);
            }

            using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                state.Output.Write(']');

            return(0);
        }
Пример #2
0
        protected override int VisitStructureValue(ThemedValueFormatterState state, StructureValue structure)
        {
            var count = 0;

            using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                state.Output.Write('{');

            var delim = string.Empty;

            for (var index = 0; index < structure.Properties.Count; ++index)
            {
                if (delim.Length != 0)
                {
                    using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                        state.Output.Write(delim);
                }

                delim = ", ";

                var property = structure.Properties[index];

                using (ApplyStyle(state.Output, HtmlThemeStyle.Name))
                    JsonValueFormatter.WriteQuotedJsonString(property.Name, state.Output);

                using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                    state.Output.Write(": ");

                count += Visit(state.Nest(), property.Value);
            }

            if (structure.TypeTag != null)
            {
                using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                    state.Output.Write(delim);

                using (ApplyStyle(state.Output, HtmlThemeStyle.Name))
                    JsonValueFormatter.WriteQuotedJsonString("$type", state.Output);

                using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                    state.Output.Write(": ");

                using (ApplyStyle(state.Output, HtmlThemeStyle.String))
                    JsonValueFormatter.WriteQuotedJsonString(structure.TypeTag, state.Output);
            }

            using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                state.Output.Write('}');

            return(count);
        }
Пример #3
0
        protected override int VisitDictionaryValue(ThemedValueFormatterState state, DictionaryValue dictionary)
        {
            var count = 0;

            using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                state.Output.Write('{');

            var delim = string.Empty;

            foreach (var element in dictionary.Elements)
            {
                if (delim.Length != 0)
                {
                    using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                        state.Output.Write(delim);
                }

                delim = ", ";

                using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                    state.Output.Write('[');

                using (ApplyStyle(state.Output, HtmlThemeStyle.String))
                    count += Visit(state.Nest(), element.Key);

                using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                    state.Output.Write("]=");

                count += Visit(state.Nest(), element.Value);
            }

            using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                state.Output.Write('}');

            return(count);
        }
Пример #4
0
        protected override int VisitDictionaryValue(ThemedValueFormatterState state, DictionaryValue dictionary)
        {
            var count = 0;

            using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                state.Output.Write('{');

            var delim = string.Empty;

            foreach (var element in dictionary.Elements)
            {
                if (delim.Length != 0)
                {
                    using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                        state.Output.Write(delim);
                }

                delim = ", ";

                var style = element.Key.Value == null
                    ? HtmlThemeStyle.Null
                    : element.Key.Value is string
                            ?HtmlThemeStyle.String
                            : HtmlThemeStyle.Scalar;

                using (ApplyStyle(state.Output, style))
                    JsonValueFormatter.WriteQuotedJsonString((element.Key.Value ?? "null").ToString(), state.Output);

                using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                    state.Output.Write(": ");

                count += Visit(state.Nest(), element.Value);
            }

            using (ApplyStyle(state.Output, HtmlThemeStyle.TertiaryText))
                state.Output.Write('}');

            return(count);
        }