< Summary

Class:Microsoft.Azure.Search.Serialization.InjectingJsonWriter
Assembly:Microsoft.Azure.Search.Data
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Data\src\Customizations\Serialization\InjectingJsonWriter.cs
Covered lines:43
Uncovered lines:77
Coverable lines:120
Total lines:309
Line coverage:35.8% (43 of 120)
Covered branches:4
Total branches:4
Branch coverage:100% (4 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
get_OnStart()-100%100%
Close()-0%100%
Flush()-0%100%
WriteComment(...)-0%100%
WriteEnd()-0%100%
WriteEndArray()-100%100%
WriteEndConstructor()-0%100%
WriteEndObject()-100%100%
WriteNull()-100%100%
WritePropertyName(...)-100%100%
WritePropertyName(...)-100%100%
WriteRaw(...)-0%100%
WriteRawValue(...)-0%100%
WriteStartArray()-100%100%
WriteStartConstructor(...)-0%100%
WriteStartObject()-100%100%
WriteUndefined()-0%100%
WriteValue(...)-100%100%
WriteValue(...)-100%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-100%100%
WriteValue(...)-100%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-100%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-100%100%
WriteValue(...)-100%100%
WriteValue(...)-100%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-100%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteWhitespace(...)-0%100%
AfterStart()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Data\src\Customizations\Serialization\InjectingJsonWriter.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for
 3// license information.
 4
 5namespace Microsoft.Azure.Search.Serialization
 6{
 7    using System;
 8    using Newtonsoft.Json;
 9
 10    /// <summary>
 11    /// Allows injection of arbitrary JSON during serialization via a callback.
 12    /// </summary>
 13    internal class InjectingJsonWriter : JsonWriter
 14    {
 15        private JsonWriter _innerWriter;
 16        private bool _wasStartProcessed;
 17
 2750818        public InjectingJsonWriter(JsonWriter innerWriter)
 19        {
 2750820            _innerWriter = innerWriter;
 2750821            _wasStartProcessed = false;
 2750822        }
 23
 8252424        public Action<JsonWriter> OnStart { get; set; }
 25
 26        public override void Close()
 27        {
 028            _innerWriter.Close();
 029        }
 30
 31        public override void Flush()
 32        {
 033            _innerWriter.Flush();
 034        }
 35
 36        public override void WriteComment(string text)
 37        {
 038            _innerWriter.WriteComment(text);
 039        }
 40
 41        public override void WriteEnd()
 42        {
 043            _innerWriter.WriteEnd();
 044        }
 45
 46        public override void WriteEndArray()
 47        {
 586648            _innerWriter.WriteEndArray();
 586649        }
 50
 51        public override void WriteEndConstructor()
 52        {
 053            _innerWriter.WriteEndConstructor();
 054        }
 55
 56        public override void WriteEndObject()
 57        {
 3141258            _innerWriter.WriteEndObject();
 3141259        }
 60
 61        public override void WriteNull()
 62        {
 5863            _innerWriter.WriteNull();
 5864        }
 65
 66        public override void WritePropertyName(string name)
 67        {
 410468            _innerWriter.WritePropertyName(name);
 410469        }
 70
 71        public override void WritePropertyName(string name, bool escape)
 72        {
 6310873            _innerWriter.WritePropertyName(name, escape);
 6310874        }
 75
 76        public override void WriteRaw(string json)
 77        {
 078            _innerWriter.WriteRaw(json);
 079        }
 80
 81        public override void WriteRawValue(string json)
 82        {
 083            _innerWriter.WriteRawValue(json);
 084        }
 85
 86        public override void WriteStartArray()
 87        {
 586688            _innerWriter.WriteStartArray();
 586689            AfterStart();
 586690        }
 91
 92        public override void WriteStartConstructor(string name)
 93        {
 094            _innerWriter.WriteStartConstructor(name);
 095            AfterStart();
 096        }
 97
 98        public override void WriteStartObject()
 99        {
 31412100            _innerWriter.WriteStartObject();
 31412101            AfterStart();
 31412102        }
 103
 104        public override void WriteUndefined()
 105        {
 0106            _innerWriter.WriteUndefined();
 0107        }
 108
 109        public override void WriteValue(bool value)
 110        {
 86111            _innerWriter.WriteValue(value);
 86112        }
 113
 114        public override void WriteValue(bool? value)
 115        {
 5084116            _innerWriter.WriteValue(value);
 5084117        }
 118
 119        public override void WriteValue(byte value)
 120        {
 0121            _innerWriter.WriteValue(value);
 0122        }
 123
 124        public override void WriteValue(byte? value)
 125        {
 0126            _innerWriter.WriteValue(value);
 0127        }
 128
 129        public override void WriteValue(byte[] value)
 130        {
 0131            _innerWriter.WriteValue(value);
 0132        }
 133
 134        public override void WriteValue(char value)
 135        {
 0136            _innerWriter.WriteValue(value);
 0137        }
 138
 139        public override void WriteValue(char? value)
 140        {
 0141            _innerWriter.WriteValue(value);
 0142        }
 143
 144        public override void WriteValue(DateTime value)
 145        {
 0146            _innerWriter.WriteValue(value);
 0147        }
 148
 149        public override void WriteValue(DateTime? value)
 150        {
 0151            _innerWriter.WriteValue(value);
 0152        }
 153
 154        public override void WriteValue(DateTimeOffset value)
 155        {
 80156            _innerWriter.WriteValue(value);
 80157        }
 158
 159        public override void WriteValue(DateTimeOffset? value)
 160        {
 1970161            _innerWriter.WriteValue(value);
 1970162        }
 163
 164        public override void WriteValue(decimal value)
 165        {
 0166            _innerWriter.WriteValue(value);
 0167        }
 168
 169        public override void WriteValue(decimal? value)
 170        {
 0171            _innerWriter.WriteValue(value);
 0172        }
 173
 174        public override void WriteValue(double value)
 175        {
 5200176            _innerWriter.WriteValue(value);
 5200177        }
 178
 179        public override void WriteValue(double? value)
 180        {
 0181            _innerWriter.WriteValue(value);
 0182        }
 183
 184        public override void WriteValue(float value)
 185        {
 0186            _innerWriter.WriteValue(value);
 0187        }
 188
 189        public override void WriteValue(float? value)
 190        {
 0191            _innerWriter.WriteValue(value);
 0192        }
 193
 194        public override void WriteValue(Guid value)
 195        {
 0196            _innerWriter.WriteValue(value);
 0197        }
 198
 199        public override void WriteValue(Guid? value)
 200        {
 0201            _innerWriter.WriteValue(value);
 0202        }
 203
 204        public override void WriteValue(int value)
 205        {
 90206            _innerWriter.WriteValue(value);
 90207        }
 208
 209        public override void WriteValue(int? value)
 210        {
 3138211            _innerWriter.WriteValue(value);
 3138212        }
 213
 214        public override void WriteValue(long value)
 215        {
 34216            _innerWriter.WriteValue(value);
 34217        }
 218
 219        public override void WriteValue(long? value)
 220        {
 0221            _innerWriter.WriteValue(value);
 0222        }
 223
 224        public override void WriteValue(object value)
 225        {
 0226            _innerWriter.WriteValue(value);
 0227        }
 228
 229        public override void WriteValue(sbyte value)
 230        {
 0231            _innerWriter.WriteValue(value);
 0232        }
 233
 234        public override void WriteValue(sbyte? value)
 235        {
 0236            _innerWriter.WriteValue(value);
 0237        }
 238
 239        public override void WriteValue(short value)
 240        {
 0241            _innerWriter.WriteValue(value);
 0242        }
 243
 244        public override void WriteValue(short? value)
 245        {
 0246            _innerWriter.WriteValue(value);
 0247        }
 248
 249        public override void WriteValue(string value)
 250        {
 53580251            _innerWriter.WriteValue(value);
 53580252        }
 253
 254        public override void WriteValue(TimeSpan value)
 255        {
 0256            _innerWriter.WriteValue(value);
 0257        }
 258
 259        public override void WriteValue(TimeSpan? value)
 260        {
 0261            _innerWriter.WriteValue(value);
 0262        }
 263
 264        public override void WriteValue(uint value)
 265        {
 0266            _innerWriter.WriteValue(value);
 0267        }
 268
 269        public override void WriteValue(uint? value)
 270        {
 0271            _innerWriter.WriteValue(value);
 0272        }
 273
 274        public override void WriteValue(ulong value)
 275        {
 0276            _innerWriter.WriteValue(value);
 0277        }
 278
 279        public override void WriteValue(ulong? value)
 280        {
 0281            _innerWriter.WriteValue(value);
 0282        }
 283
 284        public override void WriteValue(Uri value)
 285        {
 0286            _innerWriter.WriteValue(value);
 0287        }
 288
 289        public override void WriteValue(ushort value)
 290        {
 0291            _innerWriter.WriteValue(value);
 0292        }
 293
 294        public override void WriteWhitespace(string ws)
 295        {
 0296            _innerWriter.WriteWhitespace(ws);
 0297        }
 298
 299        private void AfterStart()
 300        {
 37278301            if (!_wasStartProcessed && OnStart != null)
 302            {
 27508303                OnStart(_innerWriter);
 304            }
 305
 37278306            _wasStartProcessed = true;
 37278307        }
 308    }
 309}