private static void Read( string content, params RawJson[] raw ) { var sr = new StringReader(content); using( var reader = new JsonReader(sr) ) { Assert.Throws<InvalidOperationException>(() => reader.Token.NotNullReference()); Assert.Throws<InvalidOperationException>(() => reader.RawValue.NotNullReference()); if( raw.NullReference() || raw.Length == 0 ) { Assert.False(reader.Read()); } else { foreach( var r in raw ) { Assert.True(reader.Read()); Assert.AreEqual(r.Token, reader.Token); Test.OrdinalEquals(r.RawValue, reader.RawValue); } Assert.False(reader.Read()); } Assert.False(reader.Read()); Assert.Throws<InvalidOperationException>(() => reader.Token.NotNullReference()); Assert.Throws<InvalidOperationException>(() => reader.RawValue.NotNullReference()); } }
private JsonDataStoreReader( JsonReader jsonReader, bool isDataStoreJson ) : base() { Ensure.That(jsonReader).NotNull(); this.jsonReader = jsonReader; this.textReader = new IO.StringReader(); this.parents = new Stack<ParentInfo>(); this.isDataStoreJson = isDataStoreJson; }
/// <summary> /// Called when the object is being disposed of. Inheritors must call base.OnDispose to be properly disposed. /// </summary> /// <param name="disposing">If set to <c>true</c>, release both managed and unmanaged resources; otherwise release only the unmanaged resources.</param> protected override void OnDispose( bool disposing ) { if( disposing ) { //// dispose-only (i.e. non-finalizable) logic //// (managed, disposable resources you own) if( this.jsonReader.NotNullReference() ) { this.jsonReader.Dispose(); this.jsonReader = null; } } //// shared cleanup logic //// (unmanaged resources) this.currentValue = null; this.textReader = null; base.OnDispose(disposing); }