Exemple #1
0
        // ===================[ Interface Methods ]===========================

        public JsonValue AppendNew(JsonBuilder valueBuilder)
        {
            int currTabbing = JsonHelper.EvaluteBegginningTabOffset(this, valueBuilder.BuilderSettings);

            int startIndex = this.OffsetInSource + this.StringValue.Length - 1;

            JsonHelper.FindInsertStart(this.Source.Text, ref startIndex);

            var trackerBuilder = new IndexTrackingStringBuilder(startIndex);

            if (this.Count > 0)
            {
                trackerBuilder.Write(",");
            }
            JsonBuilder.MakeNewline(trackerBuilder, currTabbing, valueBuilder.BuilderSettings);

            this.Source.BeginPlaceholderMode(trackerBuilder);
            JsonValue value = valueBuilder.BuildJsonValue(this.Source, trackerBuilder, currTabbing);

            this.Add(value);
            this.Source.PlaceholderSetupComplete();
            return(value);
        }
Exemple #2
0
        public JsonValue AppendNew(string key, JsonBuilder valueBuilder)
        {
            int currTabbing = JsonHelper.EvaluteBegginningTabOffset(this, valueBuilder.BuilderSettings);

            int startIndex = this.OffsetInSource + this.StringValue.Length - 1;

            JsonHelper.FindInsertStart(this.Source.Text, ref startIndex);

            var trackerBuilder = new IndexTrackingStringBuilder(startIndex);

            if (this.Count > 0)
            {
                trackerBuilder.Write(",");
            }

            JsonBuilder.MakeNewline(trackerBuilder, currTabbing, valueBuilder.BuilderSettings);

            // Add the key part. This will actually be invalid until the PlaceholderSetupComplete happens
            JsonBuilder.WritePropertyHeading(trackerBuilder, key, out int keyStart, valueBuilder.BuilderSettings);

            if (!valueBuilder.IsValue)
            {
                JsonBuilder.MakeNewline(trackerBuilder, currTabbing, valueBuilder.BuilderSettings);
            }


            this.Source.BeginPlaceholderMode(trackerBuilder);
            TrackedString trackedKey = new TrackedString(this.Source, keyStart, key);

            JsonValue value = valueBuilder.BuildJsonValue(this.Source, trackerBuilder, currTabbing);

            this.Add(trackedKey, value);
            this.Source.PlaceholderSetupComplete();

            return(value);
        }